Skip to content

Instantly share code, notes, and snippets.

@GitaiQAQ
Created June 1, 2022 15:44
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 GitaiQAQ/7095148d90f0c3dca8c83b79c5d4dc37 to your computer and use it in GitHub Desktop.
Save GitaiQAQ/7095148d90f0c3dca8c83b79c5d4dc37 to your computer and use it in GitHub Desktop.
useForceUpdate
const useForceUpdate = () => Object.assign.apply(null, useReducer(({ current }) => ({ current: current + 1 }), { current: 0 }).reverse());
functioin Test() {
const forceUpdate = useForceUpdate();
const dataMap = useMemo(() => new WeakMap(), [forceUpdate.current]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment