Question:
I have read similar questions, but still can’t explain why the passed state to child components, which is defined as a separate state in there (for event controlling reasons), doesn’t get updated and therefore renders the children, while it got updated in the parent.Please check this CodeSandbox or the below snippet to see the problem. (The parent state changes on inputs’ onChange event in child components, but it doesn’t re-render the children with the updated value).
Thanks.
Answer:
In your InputComponent you set the value using internal state. You assign it once and that’s it. Once it’s assigned it’s original value it doesn’t keep listening to changes in the passed down state.If you have better answer, please add a comment about this, thank you!