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

set up help #15

Open
Jbarget opened this issue Aug 31, 2016 · 11 comments
Open

set up help #15

Jbarget opened this issue Aug 31, 2016 · 11 comments

Comments

@Jbarget
Copy link

Jbarget commented Aug 31, 2016

My components use plain javascript objects as their props am I right in thinking that I only need to use redux-persist-transform-immutable and not redux-persist-immutable-state?

When trying to implement redux-persist-transform-immutable im getting an error, when the persistStore function gets run its turning the state from an Immutable.Map into a JS object version of the Immutable.Map, which is causing the syncHistoryWithStore to give the error in the console.

Any help would be great!
Thanks

screen shot 2016-08-31 at 14 33 17

Persister HOC (persistStore gets run on componentWillMount)

persistStore(store, {transforms: [immutableTransform({})]}, () => {
    console.log('rehydration complete');
});

Instructions from redux-immutable:

const history = syncHistoryWithStore(browserHistory, store, {
  selectLocationState(state) {
    console.log('2>>>>>>>>>>>', state)
    return state.get('routing').toJS();
  }
});

Store configuration:

import thunkMiddleware from 'redux-thunk';
import { autoRehydrate } from 'redux-persist';
import { routerMiddleware } from 'react-router-redux';
import rootReducer from '../reducers/index';
import { createStore, applyMiddleware, compose } from 'redux';

function configureStore(browserHistory) {
  return createStore(
    rootReducer,
    compose(
      autoRehydrate(),
      applyMiddleware(thunkMiddleware, routerMiddleware(browserHistory))
    )
  );
}

export default configureStore;
@Jbarget Jbarget changed the title usage with redux-immutable set up help Aug 31, 2016
@rt2zz
Copy link
Owner

rt2zz commented Aug 31, 2016

It looks like this line return state.get('routing').toJS(); expects your state to be an Immutable Map. Changing that to return state.routing.toJS(); may solve your issue. Otherwise I would advise waiting a few days until we have chance to ship proper immutable support in redux-persist.

@Jbarget
Copy link
Author

Jbarget commented Aug 31, 2016

@rt2zz thanks man, ah didnt realise that was in the pipeline. Will keep an eye out!

@Jbarget
Copy link
Author

Jbarget commented Sep 7, 2016

@rt2zz just wondering if theres any timeline on the immutable support you mentioned?

@rt2zz
Copy link
Owner

rt2zz commented Sep 9, 2016

Not sure, potentially this weekend!

@braco
Copy link

braco commented Sep 10, 2016

@rt2zz : not sure what you have planned, but it would be great if the coming changes were seamless-immutable compatible. The API is almost the same.

@rt2zz
Copy link
Owner

rt2zz commented Sep 16, 2016

Ok tentative immutable support for redux-persist now available at https://github.com/rt2zz/redux-persist-immutable.

note I have not actually run this in an app, but the tests pass ;)

@Jbarget
Copy link
Author

Jbarget commented Sep 16, 2016

thanks @rt2zz!
just getting an error when trying to implement see here

@rt2zz
Copy link
Owner

rt2zz commented Sep 16, 2016

@braco if you can weigh in on what changes are needed for seamless-immutable support, I believe it should be easy to add in. Right now we reply on Map.get() in particular

@braco
Copy link

braco commented Sep 17, 2016

Paging @rtfeldman

@braco
Copy link

braco commented Sep 17, 2016

@rt2zz: where's the code currently residing so I can take a look?

@rt2zz
Copy link
Owner

rt2zz commented Sep 19, 2016

@braco code in question is here: https://github.com/rt2zz/redux-persist-immutable

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