Last active
June 29, 2022 08:32
-
-
Save avcs06/4ac2ef7f6eb3828900ef6e687ad003b3 to your computer and use it in GitHub Desktop.
Follows the changes of dependencies except the first one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react'; | |
const useLazyEffect = (callback, deps) => { | |
const firstRender = useRef(true); | |
useEffect(() => { | |
if (firstRender.current) { | |
firstRender.current = false; | |
} else callback(); | |
}, deps); | |
}; | |
export default useLazyEffect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment