Before React hooks, I would use componentDidUpdate(prevProps, prevState), and if I wanted to execute given code only when this.state.a had updated, I'd do
if (prevState.a !== this.state.a) {
<...>
}
How can I achieve the same thing in useEffect()?
useEffecthook. Seems also others here may've missed the part that you want to compare to a previous value.