Skip to content

Commit dfc69cb

Browse files
committed
Merge pull request #2169 from timdorr/location-change
Update server rendering docs
2 parents d605537 + 43902bd commit dfc69cb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/guides/advanced/ServerRendering.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ to:
1010
To facilitate these needs, you drop one level lower than the [`<Router/>`](/docs/API.md#Router)
1111
API with:
1212

13-
- `createLocation` from the history package
13+
- `createMemoryHistory` from the history package
1414
- `match` to match the routes to a location without rendering
1515
- `RoutingContext` for synchronous rendering of route components
1616

1717
It looks something like this with an imaginary JavaScript server:
1818

1919
```js
20-
import createLocation from 'history/lib/createLocation'
20+
import createMemoryHistory from 'history/lib/createMemoryHistory'
2121
import { RoutingContext, match } from 'react-router'
2222
import routes from './routes'
2323
import { renderToString } from 'react-dom/server'
2424

2525
serve((req, res) => {
26-
let location = createLocation(req.url)
26+
const history = createMemoryHistory()
27+
const location = history.createLocation(req.url)
2728

28-
match({ routes, location }, (error, redirectLocation, renderProps) => {
29+
match({ routes, history, location }, (error, redirectLocation, renderProps) => {
2930
if (redirectLocation)
3031
res.redirect(301, redirectLocation.pathname + redirectLocation.search)
3132
else if (error)

0 commit comments

Comments
 (0)