Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 10x 10x 6x 6x | import {useEffect, useRef} from 'react' /** * A custom useEffect hook that only triggers on updates, not on initial mount * @param {Function} effect * @param {Array<any>} dependencies */ const useUpdateEffect = (effect = () => null, dependencies = []) => { const isInitialMount = useRef(true) useEffect(() => { Eif (isInitialMount.current) { isInitialMount.current = false } else { return effect() } }, dependencies) // eslint-disable-line react-hooks/exhaustive-deps } export default useUpdateEffect |