3 ms·
I went and checked, and it is a bit buried at the bottom of the useState explanation when explaining what an example does: > Line 9: When the user clicks, we c
by nitwit005 4y ago
I went and checked, and it is a bit buried at the bottom of the useState explanation when explaining what an example does:
> Line 9: When the user clicks, we call setCount with a new value. React will then re-render the Example component, passing the new count value to it.
https://reactjs.org/docs/hooks-state.html https://reactjs.org/docs/hooks-state.html
I think they assume you'll figure out that it must do so to function at all.
- bobthepanda 4y agoThis has been true even in the old class components. A component always updates when props update.
- throwaway290 4y agoIt's about state not props. But yes state is more or less implicit props.
- Izkata 4y agoI had a co-worker that assumed it worked template-style, where the value in the JSX would update and what's on the page would re-render, but the component function wouldn't be re-run.