Created
March 16, 2020 07:36
-
-
Save parties/bd9b3e040f1347570c3d6af57a56f83f to your computer and use it in GitHub Desktop.
useForceUpdate hook
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
function useForceUpdate () { | |
const [value, setValue] = React.useState(0) // integer state | |
return () => setValue(value => ++value) // update the state to force render | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment