Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Support ImmutableJS: use getLocationState instead of getRouterState as mentioned in #140 #218

Merged
merged 1 commit into from
Jan 24, 2016

Conversation

stepankuzmin
Copy link
Contributor

This works for me with custom reducer:

import { UPDATE_LOCATION } from 'redux-simple-router'

const initialState = new Immutable.Map({
  location: undefined
})

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

  return state.merge({ location })
}

and this selectLocationState

  const selectLocationState = function (state) {
    const location = state.get('routing').get('location')
    return location ? location.toJS() : location
  }

@timdorr
Copy link
Member

timdorr commented Jan 20, 2016

This is really less about supporting Immutable explicitly, and more about being less prescriptive about the return shape of our selectRouterState/selectLocationState. That seems like a positive API change to me.

@timdorr
Copy link
Member

timdorr commented Jan 20, 2016

I'm going to leave this open until we want to do a release, since it affects the docs on master. I don't want to confuse people using the published version when the behavior differs from the docs.

In the meantime, you should be able to do this with your selectRouterState:

const selectLocationState = function (state) {
  const location = state.get('routing').get('location')
  return { location: location ? location.toJS() : location }
}

@stepankuzmin
Copy link
Contributor Author

Yep, thanks for reply @timdorr! I've also updated README.md in this PR to track changes

timdorr added a commit that referenced this pull request Jan 24, 2016
Support ImmutableJS: use getLocationState instead of getRouterState as mentioned in #140
@timdorr timdorr merged commit 0574e4d into reactjs:master Jan 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants