From 26269dfe5151a403b58beadbd52186281febdc8a Mon Sep 17 00:00:00 2001 From: Brad Estey Date: Thu, 24 Mar 2016 11:08:09 -0400 Subject: [PATCH] Show Scroll Behavior upgrade example. Since use of `scroll-behavior` is so popular, maybe show an example of how to upgrade it in the v2 upgrade guide. --- upgrade-guides/v2.0.0.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/upgrade-guides/v2.0.0.md b/upgrade-guides/v2.0.0.md index fccae01858..b93bc7193e 100644 --- a/upgrade-guides/v2.0.0.md +++ b/upgrade-guides/v2.0.0.md @@ -82,6 +82,24 @@ const appHistory = useRouterHistory(createHashHistory)({ queryKey: false }) ``` +### Using Scroll Behavior + +```js +// v1.x +import createBrowserHistory from 'history/lib/createBrowserHistory' +import useScroll from 'scroll-behavior/lib/useStandardScroll' +const history = useScroll(createBrowserHistory)() + + +// 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))(); + +``` + ## 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`.