-
Notifications
You must be signed in to change notification settings - Fork 2
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
State is not updated for put/get sequence #6
Comments
imo, it's probably best document this as a known issue / difference between using sagas in redux vs in useReducer, so that react fiber can keep things speedy. |
@forivall I don't think that's enough. This is a serious blocker for me and I think possibly for many other developers from using this hook. When one start building more complex sagas (which I assume one will, since sagas are suitable for solving complex problems), you can hardly write reliable code when your saga may get outdated state. |
@richard-ejem have you found any reliable solution or workaround for the problem? |
@alex-kowalczyk we ended up with writing our own abstraction of React state for complex components, which has a way to get immediate state thanks to internal use of useRef. It seems this cannot be achieved with pure |
@forivall I agree with @richard-ejem this is a quite fundamental issue, as the state received by I found an article describing a way to solve that: Do you think this could work? |
Yeah, I was giving this a bit of thought a while back, and I'm thinking that it could be possible to leverage the scheduler library that react uses internally, although i only briefly investigated it. |
See my example app:
https://github.com/richard-ejem/use-saga-reducer-test/blob/master/src/App.tsx#L12
When redux-saga is used with redux, updated state is available to
select
s immediately, however withuseSagaReducer
it is not.The probable cause is that redux
dispatch
updates the synchronously while react'suseState
/useReducer
does not, however I have no idea how to fix it elegantly.The text was updated successfully, but these errors were encountered: