Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImmerHook return type, Dispatch type fix #47

Merged
merged 7 commits into from
Apr 6, 2020

Conversation

Plasmoxy
Copy link
Contributor

Hello, I've encountered a situation where I needed the return type of useImmer<T>, however TypeScript's ReturnType<T> doesn't work with generic return types (microsoft/TypeScript#26856).

I would like to add a type alias for this return type ( [T, (f: (d: Draft<T>) => T | void) => void]) called ImmerHook (feel free to rename it appropriately).

Also I have noticed the useImmerReducer<S, A> uses React.Dispatch, however React is not imported. Is this intended ? I have fixed it by adding {Dispatch} import.

Plasmoxy and others added 7 commits February 15, 2020 12:46
Bumps [acorn](https://github.com/acornjs/acorn) from 6.1.1 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@6.1.1...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
Previously, this called `produce()` on every render but discarded the result on every render where `reducer` didn't change. Now, we use useMemo, which only calls it when `reducer` changes. (useCallback is really only intended for a function literal first argument.)
…orn-6.4.1

Bump acorn from 6.1.1 to 6.4.1
useImmerReducer: only call produce() when reducer changes
@mweststrate mweststrate merged commit 9c3f74f into immerjs:master Apr 6, 2020
@mweststrate
Copy link
Collaborator

Released in 0.4.0, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants