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

selectLocationState not working? #408

Closed
@bitspook

Description

@bitspook

I have wrapped my state in Immutable.js, so I am using selectLocationState in syncHistoryWithStore options as specified in docs. But I am facing a weird issue. On the initial app load, I redirect from / to /locations using IndexRedirect. When the app loads, it dispatches 2 actions, first to change location to /, and second to change it to /locations. The location in url-bar flickers to /locations for half a second, and then change back to /. window.history.state.key shows the id of / location, but the location in state.routing is /locations. Even when I try to history.back() or use browser navigation to go back, the location changes for half a second and then change to / again.

Same happens when I click on <Link>s.

Here is how I am creating history that is passed to <Router>:

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

Here's my reducer:

import { LOCATION_CHANGE } from 'react-router-redux';
...
    routing: (state, action) => {
        if (action.type === LOCATION_CHANGE) {
            return state.merge(action.payload);
        }

        return state;
    },
...

Do you have an idea of what I might be doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions