Accepted answer

useEffect takes a second argument which denotes when to execute the effect. You can pass in the state value to it so that it executes when state updates. Also you can have multiple useEffect hooks in your code

const [propA, setPropA] = useState(props.propA);
const [propB, setPropB] = useState(props.propB);

useEffect(() => { 
}, [propA]);

useEffect(() => { 
}, [propB]);
  <button onClick={e => {setPropA(}}>Prop A</button>
  <button onClick={e => {setPropB(}}>Prop B</button>

Related Query

More Query from same tag