react-native-ui-lib
Version:
[](https://stand-with-ukraine.pp.ua)
16 lines (15 loc) • 371 B
JavaScript
import { useEffect, useRef } from 'react';
/**
* This hook avoid calling useEffect on the initial value of his dependency array
*/
const useDidUpdate = (callback, dep) => {
const isMounted = useRef(false);
useEffect(() => {
if (isMounted.current) {
callback();
} else {
isMounted.current = true;
}
}, dep);
};
export default useDidUpdate;