You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using redux-router with isomorphic-fetch server side and ran across an issue if you do not pass a createHistory object into reduxReactRouter({ routes: routes }) in a server.js file in beta4.
This is the error thrown within history:
TypeError: Cannot read property 'apply' of undefined
at Object.createLocation (/node_modules/history/lib/useQueries.js:99:45)
Before beta4 passing the createHistory property was optional from redux-router/server and createLocation from the requested url just worked. The workaround that I am using is to just call reduxReactRouter({ routes: routes, createHistory: createHistory }) when composing the server store. Note that you can't use createBrowserHistory as it requires a DOM.
Might be nice to auto create a default history object on the server if one does not exist. Another option would be to pass in the location instead of just the url...
Instead of this:
app.use((req, res) => {
store.dispatch(match(req.url, (error, redirectLocation, routerState) => {
// do your rendering here
}))
})
You would use this (this is how react-router expects the location in their match method):
import createLocation from 'history/lib/createLocation'
app.use((req, res) => {
const location = createLocation(req.url)
store.dispatch(match(location, (error, redirectLocation, routerState) => {
// do your rendering here
}))
})
The text was updated successfully, but these errors were encountered:
I am using redux-router with isomorphic-fetch server side and ran across an issue if you do not pass a
createHistory
object intoreduxReactRouter({ routes: routes })
in a server.js file in beta4.This is the error thrown within history:
Before beta4 passing the
createHistory
property was optional fromredux-router/server
andcreateLocation
from the requested url just worked. The workaround that I am using is to just callreduxReactRouter({ routes: routes, createHistory: createHistory })
when composing the server store. Note that you can't usecreateBrowserHistory
as it requires a DOM.Might be nice to auto create a default history object on the server if one does not exist. Another option would be to pass in the location instead of just the url...
Instead of this:
You would use this (this is how react-router expects the location in their
match
method):The text was updated successfully, but these errors were encountered: