Skip to content

Commit

Permalink
fix(useForceUpdate): ensure that chained calls produce an update
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 22, 2024
1 parent 54590c5 commit 3744b63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useForceUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ import { useReducer } from 'react'
export default function useForceUpdate(): () => void {
// The toggling state value is designed to defeat React optimizations for skipping
// updates when they are strictly equal to the last state value
const [, dispatch] = useReducer((state: boolean) => !state, false)
const [, dispatch] = useReducer((revision) => revision + 1, 0)
return dispatch as () => void
}

0 comments on commit 3744b63

Please sign in to comment.