Skip to content

Commit

Permalink
refactor(react): use force update return type (toss#204)
Browse files Browse the repository at this point in the history
* refactor(react): Change how return type is specified

* docs(react): useForceUpdate note fix

* docs: useForceUpdate jsdoc @link

Co-authored-by: Jonghyeon Ko <[email protected]>

---------

Co-authored-by: Jonghyeon Ko <[email protected]>
Co-authored-by: Sojin Park <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2023
1 parent 75b0150 commit 6fcd8c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react/react/src/hooks/useForceUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const updater = (num: number): number => (num + 1) % 1_000_000;
* @description
* 반환된 함수를 실행 시 강제로 리렌더가 실행됩니다.
*
* @note useReduce가 state보다 조금 더 저렴(?) 하다고 합니다. https://github.com/streamich/react-use/pull/837
* @note {@link https://github.com/streamich/react-use/pull/837 useReduce가 state보다 가볍다는 의견이 있습니다.}
*/
export function useForceUpdate() {
export function useForceUpdate(): () => void {
const [, forceUpdate] = useReducer(updater, 0);

return forceUpdate as () => void;
return forceUpdate;
}

0 comments on commit 6fcd8c3

Please sign in to comment.