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()
?