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

react-router-redux really needs a custom reducer? #19

Closed
remojansen opened this issue Feb 18, 2016 · 4 comments
Closed

react-router-redux really needs a custom reducer? #19

remojansen opened this issue Feb 18, 2016 · 4 comments
Labels

Comments

@remojansen
Copy link

The docs say the following:

react-router-redux routeReducer does not work with Immutable.js. 

However, it seems to be supported.

Can you guys please clarify this?

Thanks!

@gajus
Copy link
Owner

gajus commented Feb 18, 2016

@remojansen The issue that you have referenced to says:

Closing because I just saw the 3rd argument to syncReduxAndRouter method allowing you to pass in a function to select the routing state.

Which is exactly what the docs tell you do to: https://github.com/gajus/redux-immutable/tree/ac78103fc6939ef24c713f5a765f1b7187b9891c#using-with-react-router-redux

@gajus gajus added the question label Feb 18, 2016
@gajus
Copy link
Owner

gajus commented Feb 18, 2016

Are you talking about reducer specifically?

I do not see how react-router-redux reducer can work with Immutabe.js data (https://github.com/reactjs/react-router-redux/blob/5f9b7ec3b2fa7e54a581b220e75aec23005b67ff/src/index.js#L36-L42):

export function routeReducer(state = initialState, { type, payload: location }) {
    if (type !== UPDATE_LOCATION) {
        return state
    }

    return { ...state, location }
}

@remojansen
Copy link
Author

I just saw that syncReduxAndRouter is now syncHistory. I get it now 😄 thanks for the help!

@gaearon
Copy link
Contributor

gaearon commented Feb 18, 2016

If you really want that part of the state to be immutable you can write your own reducer that does the same, and pass something like state => state.get('routing').toJS() to that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants