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

Some state changes are not registered #90

Closed
egeriis opened this issue May 6, 2016 · 6 comments
Closed

Some state changes are not registered #90

egeriis opened this issue May 6, 2016 · 6 comments

Comments

@egeriis
Copy link

egeriis commented May 6, 2016

I am having an issue where a couple of actions does not seems to be caught by this lib, so they are not being persisted. This is a gist of what I'm doing, where it doesn't work for me:

dispatch(uploadBegun(item.id));
fileReader(file).then(reader => {
  dispatch(createEntity( ... )).then(res => {
    dispatch(setItemDetail( item.id, ... ));
    dispatch(uploadDone( item.id ));
  });
});

I've tried to add a transformer which logs what comes in to redux-persist, and it shows the wrong data coming after the setItemDetail and uploadDone actions have been dispatched. Neither are registered.

Could this be a bug triggered by dispatching two actions "simultaneously"?

@rt2zz
Copy link
Owner

rt2zz commented May 6, 2016

Two actions simultaneously should be no problem. Could this be related to the debounce issue you reported earlier?

The only other thing I can think of is that redux-persist only stores state which changes, i.e. does not have reference eqaulity. So make sure you are not mutating your state for uploadDone, and are rather copying it, typically with a return {...newState} in your reducer.

@jburich
Copy link

jburich commented May 6, 2016

@egeriis Are you on version 3.0.3? I was having the same problem with very very similiar code and the problem was in createPresistor endState was pulling from a local state variable instead of store.getState() which causes the data to be stale. I just upgraded to 3.0.3 and that fixed the problem.

@rt2zz
Copy link
Owner

rt2zz commented May 6, 2016

@jburich fantastic, I just released 3.0.3 to solve the debounce issue, and I guess this solved collaterally 🎉 (or I guess more accurately this simply the same issue)

@egeriis
Copy link
Author

egeriis commented May 8, 2016

@jburich I am not. 3.0.2. Will try to pull 3.0.3 tomorrow and see if it has fixed my issue :)

@egeriis
Copy link
Author

egeriis commented May 8, 2016

@rt2zz Btw., definitely not state mutation, as I am using ImmutableJS to handle state changes—to ensure that there are no mutations.

I've experienced that { ... state } does not do a deep clone.

@egeriis
Copy link
Author

egeriis commented May 10, 2016

Works with 3.1.1. Great!

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

3 participants