immerjs / use-immer

Use immer to drive state with a React hooks
MIT License
4.04k stars 92 forks source link

Why does `useImmer()` not return `ImmerHook`? #84

Closed wereHamster closed 3 years ago

wereHamster commented 3 years ago

The return type of useImmer() and the ImmerHook types are slightly different. Is there a reason for that difference? In particular, why is the second element of the useImmer() return tuple not typed as Updater? For reference:

(f: (draft: Draft<S>) => void | S) => void // Updater type
(f: ((draft: Draft<S> | S) => void) | S) => void // Second element of the useImmer tuple
mweststrate commented 3 years ago

Looks like this was addressed in #78