Last active
January 11, 2023 22:53
-
-
Save leodutra/8b10ab1a678f76bc125cb4211ff21954 to your computer and use it in GitHub Desktop.
Use force update state (React)
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 { 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