I'm trying to set an onClick event to perform two actionss, the first action is to update a state in the child component and then update a state in the parent component, please share ideas on how to achieve this
I guess you need a callback state like this:
const [counter, setCounter] = useState(0);
const [parent, setParent] = useState(0);
const doSomething = () => {
setCounter(1);
}
useEffect(() => {
console.log('Do something after counter has changed', counter);
setPrent(2);
}, [counter]);