import shallowEquals from "shallow-equals" ; import useEffectAfterMount from "./useEffectAfterMount" ; import usePrevious from "./usePrevious" ; /**
 * useEffectWhenChanged is a react hook that will run effects
 * when value changed.
 */ export default function useEffectWhenChanged ( callback , deps ) { const previous = usePrevious ( deps ) ; useEffectAfterMount ( ( ) => { if ( ! shallowEquals ( deps , previous ) ) { callback ( ) ; } } , deps ) ; }