Skip to content
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

Child component state is reset to initial state if any state of parent component is changed #859

Open
MehbubRashid opened this issue Oct 13, 2022 · 0 comments

Comments

@MehbubRashid
Copy link

https://codesandbox.io/s/jolly-ully-bhehvu?file=/src/App.js

  1. Type something in the "new attribute name" input field and click on the add button. This will add a new sortable item. add as much item as you want.
  2. Each sortable item will contain an input field with an initial value. Change the initial value to something else.
  3. Again type something in the "new attribute name" field. This will cause the previously changed input value gone and reset to the initial value.

Theory: "new attribute name" input field is in the parent component and the sortable items are the child components. when we type something in the "new attribute name" field, the state of this parent component changes and it makes the states of child components reset. Why is that? what's the solution of this? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant