import { useEffect , useLayoutEffect } from 'react' ; import usePrevious from './usePrevious' ; const useChanged = ( options , cb ) => { const { value , from , to , effectFn = useEffect } = options ; const previous = usePrevious ( value ) ; effectFn ( ( ) => { if ( previous === from && value === to ) { cb ( ) ; } } , [ previous , value ] ) ; } ; export default useChanged ;