If the value of props.filters
did not change, then React would skip the effect.
// This will only re-run if the value of `props.filters` changes
useEffect(() => {
fetchSomeData(props.filters);
}, [props.filters]);
With hooks, React does this internally unlike the implementation using componentDidUpdate
where we have to compare the value of prevProps
and nextProps
against each other.
See optimizing performance by skipping effects.