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

handleActions with Immer. #371

Closed
sergeushenecz opened this issue Jan 30, 2021 · 1 comment
Closed

handleActions with Immer. #371

sergeushenecz opened this issue Jan 30, 2021 · 1 comment

Comments

@sergeushenecz
Copy link

sergeushenecz commented Jan 30, 2021

Hello everyone.
I want use immer with your library. I using now it so.
[constants.FETCH_CATEGORIES]: produce((draftState) => { setFetchCategoriesState(draftState, true)}),

[constants.FETCH_CATEGORIES_SUCCESS]: produce((draftState, { payload }) => { setFetchCategoriesState(draftState, false, payload); }),

But I think it incorrect. In the https://immerjs.github.io/immer/docs/example-reducer in the example produce function created once. In my example for each actionType i creating produce function. Could you explain me my example correct or no. And maybe i incorrect use immer with redux-actions?
Thanks for helping

@alexander-heimbuch
Copy link
Contributor

The given example (https://immerjs.github.io/immer/example-setstate#redux--immer) with immer is a very vanilla way to write reducers. So the code snippet you provided should be correct. Also see #329 with a very similar approach.

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

No branches or pull requests

2 participants