confirmLeave: passed action doesn't pass query parameters
mikeverf opened this issue · 0 comments
mikeverf commented
When using confirmLeave
in the routesMap, the action
passed in the function doesn't contain any other data that's in the search
part of the location.
My best guess would be that the issue is here:
const confirm = (location: HistoryLocation | Location) => {
const state = store.getState()
const routesMap = selectLocationState(state).routesMap
const pathname = location.pathname // Pathname will only return the part of the url before the query parameters
const action = pathToAction(pathname, routesMap, querySerializer)
const response = confirmLeave(state, action)
So I'd suggest something like
const pathname = [location.pathname, location.search].filter(Boolean).join('?')
Since in pathToAction.js we clearly expect a search part in the location:
const parts = pathname.split('?')
const search = parts[1]
const query = search && serializer && serializer.parse(search)
Does that make sense or am I missing something?
I would like to submit a PR myself, but I can't get the project to build locally (I think there's an issue with babel versions)… Any help with that is welcome as well :)