Skip to content

Commit 8e3d274

Browse files
author
Ryan Chu
committed
Replace deprecated method in react-router v2.0.0
Run this example while not logged in, redirect to routes with `onEnter={requireLogin}` hook will trigger following warning in the termninal. Warning: [react-router] `replaceState(state, pathname, query) is deprecated; use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated This page contains the detailed upgrade guide for react-touer v2.0.0 https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#link-to-onenter-and-isactive-use-location-descriptors
1 parent b4298d0 commit 8e3d274

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import {
1414
} from 'containers';
1515

1616
export default (store) => {
17-
const requireLogin = (nextState, replaceState, cb) => {
17+
const requireLogin = (nextState, replace, cb) => {
1818
function checkAuth() {
1919
const { auth: { user }} = store.getState();
2020
if (!user) {
2121
// oops, not logged in, so can't be here!
22-
replaceState(null, '/');
22+
replace('/');
2323
}
2424
cb();
2525
}

0 commit comments

Comments
 (0)