-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Document that syncing props and state is usually a bad idea #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @gaearon can I take this? Could you tell what to we need to add ? |
@jyash97 the issue is yours! I've added an "in-progress" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim. As far as what to add, how about starting with a disclaimer in State and Lifecycle and FAQ: State? |
#341 |
At a glance the section "What Shouldn’t Go in State?" seems like what this issue is asking for. |
Okay let me try one more time to update this content |
I think that's just another explanation of why state and props are different but this issue is asking for more of a warning about why syncing props to state is generally unnecessary. |
Update over the issue reactjs#337
@bvaughn |
* Translating testing-environments docs * Apply suggestions from code review Co-Authored-By: Bruno Vercelino da Hora <[email protected]> * Removing italic markup from mock word
* docs(cn): fix errors in hooks-intro.md * Update hooks-intro.md * Update hooks-intro.md
@gaearon is this still needed or is it covered in the hook version by: https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes |
We used to have a "tip" about this on the old website (a few years ago), but not anymore.
I think maybe we need to revive that section because too many people attempt to derive state from props—either in constructor or cWRP—without realizing they could just do this work in render. In 90% of cases that's exactly what they need to do.
See also https://mobile.twitter.com/EntriaTech/status/934139022204653569.
The text was updated successfully, but these errors were encountered: