Created
April 25, 2019 15:05
-
-
Save lpolito/00c2d9159bb18a61225db0a76192fda7 to your computer and use it in GitHub Desktop.
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 React from 'react'; | |
export const useOnUpdateEffect = (callback, dependencies) => { | |
const isInitRef = React.useRef(false); | |
React.useEffect(() => { | |
if (!isInitRef.current) { | |
isInitRef.current = true; | |
return; | |
} | |
callback(); | |
}, dependencies); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment