How to update the state from child in ReactJS?

Posted by Prem Tiwari | Updated on

Want to update the state from child in ReactJS? The parent is the source of truth, so the child needs to tell the parent to change its state. Pass a callback from the parent to the child, and have the child call it.

There’s an example on communicating between components in React’s docs that might be helpful too.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers