useUpdateEffect
function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void;
useEffect that skips the first render: effect runs only when deps change after the
component mounts, or after every later render when there are no deps. Its cleanup runs before
the next run and on unmount, as with useEffect. React's development Strict Mode, which mounts,
unmounts and mounts again, doesn't count as an update.
Example
import { useUpdateEffect } from "react-honey-hooks";
function Settings({ volume }: { volume: number }) {
// Not on load: only once the user changes the volume.
useUpdateEffect(() => {
toast(`Volume set to ${String(volume)}`);
}, [volume]);
return <VolumeSlider />;
}