I have a React component that is declared in the arrow-function notation. This component has a child component that is supposed to change the state of the ParentComponent. How can I achieve that? And how would it look like if we passed the change of the state as a function (changeState in this case)?
const ParentComponent = () => {
const [myState, setMyState] = useState(false);
const changeState = () => setMyState(!myState);
return(
<ChildComponent /> // pass the state variables
);
}
const ChildComponent = () => { // receive the state variables
// change state of parent component
}
ChildComponent? Why does the specific function notation matter?