one way binding react
In our case, it is easy to identify that the state should reside in the “Parent” component.
const [text, setText] = useState(“Hello”);
Now, what do we do to the “Parent” component? We pass the callback function as a prop from the parent component.
<Child changeText={(text) => setText(text)} />
Now we need a callback function in the “Child” component that is triggered when the button is clicked.
<button onClick={() => props.changeText(“World”)}>