Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active January 11, 2023 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leodutra/8b10ab1a678f76bc125cb4211ff21954 to your computer and use it in GitHub Desktop.
Save leodutra/8b10ab1a678f76bc125cb4211ff21954 to your computer and use it in GitHub Desktop.
Use force update state (React)
import { useCallback, useState } from "react"
export default function useForceUpdate(): VoidFunction {
const [, setValue] = useState<number>(performance.now())
return useCallback((): void => {
setValue(performance.now())
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment