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

Reducer action beeing dispatched twice #11

Open
Stene3 opened this issue Jan 5, 2021 · 0 comments
Open

Reducer action beeing dispatched twice #11

Stene3 opened this issue Jan 5, 2021 · 0 comments

Comments

@Stene3
Copy link

Stene3 commented Jan 5, 2021

Hi @Jibbedi,

at first I would like to say thanks for this great library. I was searching for a replacement of ngrx effect in my react application after transition from angular to react stack, but I also found a weird issue when used with FC component.

I didnt have time to analyze it more, so more details will come as soon as possible, but maybe you will have more ideas about a workaround.

When I use useReducerWithSideEffects inside the FC component which stays as a Context provider, and call an async method from the child component available from the context state, every reduce action will cause re-rendering the provider component, which, probably, re-creates useReducerWithSideEffects which will cause for the same action being dispatched again.

image

I will add a sandbox example, but maybe you also came into the same issue previously when writing this library.

Thanks,
L.


Update 1: I've checked your code which mentions the issue when StrictMode is used, but it's not this issue. Same issue occurs when StrictMode is not used. I also tried to use memoized callback for reduce and effect when creating side effect reducer, but this did not help either.

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

1 participant