-
Notifications
You must be signed in to change notification settings - Fork 6
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
Example of using react-action-buffer on v5 #14
Comments
I would expect it to still work, are you importing REHYDRATE from the right location (it changed in v5)? I have not tried redux-action-buffer alongside v5 yet, but my assumption was it would still work. |
I am trying this code:
They my application does not read the store anymore... it is always at initialState |
It seens that no action is being consumed when I make this configuration |
@githubdoramon sounds like |
@rt2zz I double checked this.... That is the exact import and the exact constant imported. Here is the full code for the store
And the print of the result |
hm, I am stumped. I will try to run your code later today and see what I can find. |
Thanks @rt2zz ... let me know if you need any information |
@rt2zz where you able to test it? Thanks |
@rt2zz any news here? |
ok I found the issue but I do not have an easy solution. Redux Persist v5 relies on sending out an action to get everything hooked up. Since action buffer captures this action, it prevents redux-persist from completing its initialization and hence everything hangs. One possible solution here is to add a "pass through list" to action-buffer to let certain actions through. But this would require a breaking change to the action buffer api, and I am not sure this is a scalable approach. Are you certain you need action buffer? I would recommend instead use |
I was just having this issue, and I think having a pass through list parameter would solve my use case. I would only be passing through one |
ya thats a good idea. Poor use of the word scalable on my part, what I meant was I did not want to start attaching seemingly disjoint api additions. But ya a pass through makes perfect sense and could be useful for other cases as well. 👍 |
PersistGate didn't worked.... Could you guys explain a little better how to implement the pass through list? I am working wit server side rendering and on every page refresh I can't get the previous state. Thanks |
import { PERSIST, REHYDRATE } from 'redux-persist/lib/constants'
actionBuffer({ passthrough: [PERSIST], breaker: REHYDRATE }, callback) note this will break on the first rehydrate call, so I would advise on using this with a single persistReducer setup. |
note: PersistGate would not be a drop in replacement for actionBuffer, it would require making sure all of your side-effects are triggered by component lifecycle methods rather than immediately upon loading of your bundle. However you say you are doing SSR, in which case I would think you would want to avoid persistence entirely. I might recommend an environment variable to conditionally persist let persistor = process.env.IS_SSR ? null : persistStore(store) edit: note I am not personally doing SSR so I defer to someone who has more first hand knowledge on the matter. Perhaps there are idioms around this that might help. |
I am not able to buffer the actions before hydration occurs on v5. Could someone give an example on how to do it?
The text was updated successfully, but these errors were encountered: