Skip to content

Instantly share code, notes, and snippets.

@parties
Created March 16, 2020 07:36
Show Gist options
  • Save parties/bd9b3e040f1347570c3d6af57a56f83f to your computer and use it in GitHub Desktop.
Save parties/bd9b3e040f1347570c3d6af57a56f83f to your computer and use it in GitHub Desktop.
useForceUpdate hook
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