Document how to update nested state properties #1101
Labels
Comments
I second this, I would love to read some detailed docs from y'all. |
I investigated on this subject a little bit: |
Hey guys! I opened a PR to document how to handle nested state properties. First contribution to the ReactJS.org project :) |
geetesh911
added a commit
to geetesh911/reactjs.org
that referenced
this issue
Oct 18, 2020
It's better to write your updater function to return new state based on old state. If you do this, then updating state for nested data is pretty straightforward. |
Has this issue been abandoned? I can pick it up and write the documentation based on the previous PR. |
Hey @silver-snoopy, you're welcome to work based on the previous PR! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In setState, what should one return from the updater function in order to update a nested property of the state? This isn't documented, and it trips a lot of people:
https://stackoverflow.com/questions/18933985/this-setstate-isnt-merging-states-as-i-would-expect
https://stackoverflow.com/questions/43040721/how-to-update-a-nested-state-in-react
https://stackoverflow.com/questions/34071160/how-to-update-object-in-react-js
etc.
The text was updated successfully, but these errors were encountered: