Skip to content

Commit bff41d2

Browse files
comments added to useForceUpdate to clarify the functions use case
1 parent bea2100 commit bff41d2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/app/components/useForceUpdate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState } from 'react';
22

3+
// This function will force a change in state and cause a re-render of the component. The state information is irrelevant but an update is needed to force a re-render
34
export default function useForceUpdate() {
4-
const [, setValue] = useState<number>(0);
5-
return () => setValue((value) => value + 1); // update state to force render
5+
const [setValue] = useState<number>(0);
6+
return () => setValue((value) => value + 1);
67
}

0 commit comments

Comments
 (0)