const [state, setState] = useState();
useEffect(() => {callbackFunction()}, [state])
Note: If you want the changes performed in the callback function to be reflected in the componentβs rendered output,
you would want to use useLayoutEffect instead of the useEffect react hook.