Can I update the state of the child from the parent?



Can I update the state of the child from the parent?


The short answer is no, React’s structure is like a tree where at the trunk you have your App component and each direct child will be like a branch, then a child of a child of App will be a branch from that branch (until we have twigs with leaves!), it is because of that structure that React only allows a one way pass of properties, being them methods or values. It could feel as if we have two-way communication between parent and child, but it is only the illusion made by a method from the parent, called by a child. If we come back to the idea of the tree, the branches can only grow outward but if the branches receive water from the rain, once absorbed, that water will be passed to the trunk towards the root. (root that can be seen as our index.js which is in charge of connecting App to the browser through the index.html file).

Now, there is a way to scape this passing props from the parent only, but it only can be achieved through a state management library like Redux.js.