Skip to content

Commit 09e5023

Browse files
albertogasparinliamqma
authored andcommitted
Update docs/router/ssr.md
Co-authored-by: Liam Ma <liam.q.ma@gmail.com>
1 parent 0438a5c commit 09e5023

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/api/components.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { appRoutes } from './routing';
3333
| ----------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
3434
| `routes` | `Routes[]` | Your application's routes |
3535
| `history` | `History` | The history instance for the router, if omitted memory history will be used (optional but recommended) |
36-
| `location` | `string` | If `history` prop is omitted, this configures the initial location for the default memory history (optional, useful for tests and storybooks) |
3736
| `basePath` | `string` | Base path string that will get prepended to all route paths (optional) |
3837
| `initialRoute` | `Route` | The route your application is initially showing, it's a performance optimisation to avoid route matching cost on initial render(optional) |
3938
| `resourceContext` | `ResourceContext` | Custom contextual data that will be provided to all your resources' `getKey` and `getData` methods (optional) |

docs/router/ssr.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ export const App = () => (
2929
);
3030
```
3131

32-
When however you need to SSR your app, we need pass different props to Router, as `createBrowserHistory` does not really work on server, so we recommend to use `location` instead (or pass your own `MemoryHistory` if needed)
32+
When you need to SSR your app, we need to pass different props to Router, as `createBrowserHistory` does not really work on server, so we recommend to use your own `MemoryHistory`
3333

3434
```js
3535
// server-app.js
36+
import { createMemoryHistory } from 'history';
3637
import { Router } from 'react-resource-router';
3738
import { App } from '../components';
3839
import { routes } from '../routing/routes';
3940

4041
export const ServerApp = ({ location }) => (
41-
<Router routes={routes} location={location}>
42+
<Router
43+
history={createMemoryHistory({ initialEntries: [location]} )}
44+
routes={routes}>
4245
<App />
4346
</Router>
4447
);
@@ -53,7 +56,7 @@ import { routes } from '../routing/routes';
5356
const history = createBrowserHistory();
5457

5558
export const ClientApp = () => (
56-
<Router routes={routes} history={history}>
59+
<Router history={history} routes={routes}>
5760
<App />
5861
</Router>
5962
);

0 commit comments

Comments
 (0)