Skip to content

Commit

Permalink
Merge pull request #3223 from BradEstey/patch-1
Browse files Browse the repository at this point in the history
Show Scroll Behavior upgrade example.
  • Loading branch information
taion committed Mar 30, 2016
2 parents ada247e + 26269df commit 49d5bff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions upgrade-guides/v2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ const appHistory = useRouterHistory(createHashHistory)({ queryKey: false })
<Router history={appHistory}/>
```

### Using Scroll Behavior

```js
// v1.x
import createBrowserHistory from 'history/lib/createBrowserHistory'
import useScroll from 'scroll-behavior/lib/useStandardScroll'
const history = useScroll(createBrowserHistory)()
<Router history={history}/>

// v2.0.0
import { Router, useRouterHistory } from 'react-router'
import createBrowserHistory from 'history/lib/createBrowserHistory';
import useScroll from 'scroll-behavior/lib/useStandardScroll';

const appHistory = useScroll(useRouterHistory(createBrowserHistory))();
<Router history={appHistory}/>
```

## Changes to `this.context`

Only an object named `router` is added to context. Accessing `this.context.history`, `this.context.location`, and `this.context.route` are all deprecated. This new object contains the methods available from `history` (such as `push`, `replace`) along with `setRouteLeaveHook`.
Expand Down

0 comments on commit 49d5bff

Please sign in to comment.