Skip to content

Commit 4fba218

Browse files
committed
Merge pull request #2643 from taion/docs-histories
Clean up histories guide a bit
2 parents 444141f + e460c36 commit 4fba218

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

docs/guides/basics/Histories.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ Get them from the history package:
1818
```js
1919
// JavaScript module import
2020
import createBrowserHistory from 'history/lib/createBrowserHistory'
21-
// or commonjs
22-
const createBrowserHistory = require('history/lib/createBrowserHistory')
21+
// or CommonJS
22+
var createBrowserHistory = require('history/lib/createBrowserHistory')
23+
24+
const history = createBrowserHistory()
25+
```
26+
27+
Then pass them into your `<Router>`:
28+
29+
```js
30+
render(
31+
<Router history={history} routes={routes} />,
32+
document.getElementById('app')
33+
)
2334
```
2435

2536
### `createHashHistory`
@@ -36,7 +47,7 @@ The DOM API that hash history uses to transition around is simply `window.locati
3647
You can disable that feature (more [here](http://rackt.org/history/stable/HashHistoryCaveats.html)):
3748
```js
3849
// Opt-out of persistent state, not recommended.
39-
let history = createHistory({
50+
let history = createHashHistory({
4051
queryKey: false
4152
});
4253
```
@@ -89,7 +100,12 @@ You might wonder why we don't fall back to hash history; the problem is that URL
89100
### `createMemoryHistory`
90101
Memory history doesn't manipulate or read from the address bar. This is how we implement server rendering. It's also useful for testing and other rendering environments (like React Native).
91102

103+
92104
## Example implementation
105+
106+
Putting this all together, if we wanted to use the HTML5 history API for our
107+
app, the client entry point would look like:
108+
93109
```js
94110
import React from 'react'
95111
import { render } from 'react-dom'

0 commit comments

Comments
 (0)