As a followup to a post a while back about communicating between React components. I’d like to discuss a couple of methods to communicate a change in state from from a child component to a parent component.
The first method is for a parent node to pass down a callback into the child component, a handler inside the child component can execute this callback which changes the state of the parent component.
The inner component
The child component takes a prop, which is a callback from the parent component.
The outer component
In the parent component we attach a handler to the callback that we pass into the child component.