Skip to content

Commit 6e705de

Browse files
committed
added history prop upgrade information
1 parent 3f5bfc9 commit 6e705de

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

upgrade-guides/v2.0.0.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,34 @@ We have done our best to provide backwards compatibility with deprecated APIs. I
2222

2323
The deprecation warnings should also lead you to the relevant part of this document. If one doesn't, please open a pull request with a fix. Also, if any part of this document could be improved, please let us know how. Confound it, our bias is often inescapable!
2424

25+
## Router `history` prop
26+
27+
### Default Hash History
28+
29+
`Router` used to default to creating a hash history, it no longer creates a default, you must provide one.
30+
31+
```js
32+
// v1.x
33+
<Router/>
34+
35+
// v2.0.0
36+
// hash history
37+
import { hashHistory } from 'react-router'
38+
<Router history={hashHistory}/>
39+
```
40+
41+
### Using Browser History
42+
43+
```js
44+
// v1.x
45+
import createBrowserHistory from 'history/lib/createBrowserHistory'
46+
<Router history={createBrowserHistory()}/>
47+
48+
// v2.0.0
49+
import { browserHistory } from 'react-router'
50+
<Router history={browserHistory}/>
51+
```
52+
2553
## New Router render prop (`RoutingContext` prop replacement)
2654

2755
You can now pass a `render` prop to `Router` for it to use for rendering. This allows you to create "middleware components" that participate in routing. Its critical for integrations with libraries like Relay, Redux, Resolver, Transmit, Async Props, etc.
@@ -240,4 +268,5 @@ const appHistory = useRouterHistory({
240268
})
241269

242270
<Router history={appHistory}/>
271+
```
243272

0 commit comments

Comments
 (0)