Skip to content

Instantly share code, notes, and snippets.

@timdorr
Last active February 17, 2016 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timdorr/dd4c622633d589a2c0f7 to your computer and use it in GitHub Desktop.
Save timdorr/dd4c622633d589a2c0f7 to your computer and use it in GitHub Desktop.
A common pitfall I'm seeing with server-side rendering in React Router
app.use(function (req, res) {
const history = createMemoryHistory() // <- No arg creates a history with the default first location: '/'
// Do some stuff with history
match({ history, routes, location: req.url }, (error, redirectLocation, renderProps) => {
app.use(function (req, res) {
const history = createMemoryHistory(req.path) // <- Provide the request path!
// This ensures the history instance is consistent during the match call below
// Do some stuff with history
match({ history, routes, location: req.url }, (error, redirectLocation, renderProps) => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment