r/reactjs • u/acemarke • Oct 22 '21
News New React Docs beta is live! Covers function components, hooks, rendering, state updates, and other key concepts
https://beta.reactjs.org/
601
Upvotes
r/reactjs • u/acemarke • Oct 22 '21
3
u/_Jeph_ Oct 22 '21
The only thing that is broken is the
handleFormChangefunction you added to the example. You have two callbacks being fired before the re-render happens. The second callback (handleFormChange) is still using the bound value ofpersonbefore it gets updated at the next re-render. ChangehandleFormChangeto the callback form ofsetStateto get the latest value ofperson, and it will work as intended.Pretty sure Dan Abramov has a better grasp of React internals than you do, BTW.