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

'search' state not getting params from url (createHashHistory) #365

Open
BraMKJ opened this issue Oct 25, 2019 · 5 comments
Open

'search' state not getting params from url (createHashHistory) #365

BraMKJ opened this issue Oct 25, 2019 · 5 comments

Comments

@BraMKJ
Copy link

BraMKJ commented Oct 25, 2019

I'm building a form/wizard which uses hashes to make it possible to go to different steps of the form (using url example.com/form#step-2 navigates to step 2 of the form for example). I can navigate between the steps via url and links without any issues.

However, in some cases we also want to to send params with the url to preload information in the form. When using createHashHistory the 'search' part of my state stays empty. I can get the params in 'search' when I use createBrowserHistory, but I can't use createBrowserHistory because I need the hashes for the navigation between steps.

For example when I use example.com/form?user=123456#step-2 I would expect 'search' to be '?user=123456'

const reducer = history => combineReducers({
    router: connectRouter(history),
    ...
})

export const connectHistory = createHashHistory({hashType: 'noslash'})

const store = createStore(
    reducer(connectHistory),
    {},
    composeEnhancers(
        applyMiddleware(
            routerMiddleware(connectHistory),
            thunk
        )
    )
)

export default store
ReactDOM.render(
    <Provider store={store}>
        <ConnectedRouter basename='/form' history={connectHistory}>
            <Application />
        </ConnectedRouter>
    </Provider>,
    document.getElementById("App")
);
@ghost
Copy link

ghost commented Nov 12, 2019

I believe the docs explicitly state not to reference hash history, you should have no issue using hashes with browser history also. I think you just need a bit of help making it work, are you still stuck?

@Tasemu
Copy link

Tasemu commented Jan 28, 2020

I believe the docs explicitly state not to reference hash history, you should have no issue using hashes with browser history also. I think you just need a bit of help making it work, are you still stuck?

I've been looking through the FAQ and and README, where does it state this?

@Tasemu
Copy link

Tasemu commented Jan 28, 2020

Also, i've migrated my app to use browserHistory and am seeing the same problem as the OP has stated. Perhaps this could be an issue?

@BraMKJ
Copy link
Author

BraMKJ commented Jan 28, 2020

I believe the docs explicitly state not to reference hash history, you should have no issue using hashes with browser history also. I think you just need a bit of help making it work, are you still stuck?

I've been looking through the FAQ and and README, where does it state this?

I can't find it either. Since starting this topic I've decided to go for a different solution alltogether, but I'm still curious as to why this didn't work.

@Tasemu
Copy link

Tasemu commented Jan 28, 2020

I believe the docs explicitly state not to reference hash history, you should have no issue using hashes with browser history also. I think you just need a bit of help making it work, are you still stuck?

I've been looking through the FAQ and and README, where does it state this?

I can't find it either. Since starting this topic I've decided to go for a different solution alltogether, but I'm still curious as to why this didn't work.

Could you tell me what solution you're using now? my application relies on the location redux information being up to date when changing routes in order to show messages etc, this functionality no longer works due to this issue. :)

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

2 participants