Uncaught Invariant Violation: Rendered more hooks than during the previous render
The fix works because the first code sample (the erroring one) invokes a function inside onClick, while the second (the working one) passes a function to onClick. The difference is those all-important parentheses, which in JavaScript mean ‘invoke this code’. Think of it this way: in the first code sample, every time component is rendered, renderResults is invoked. Every time that … Read more