You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To install this hook, use the `Lifecycle` mixin in one of your [route component](/docs/Glossary.md#routecomponent)s.
9
9
10
10
```js
11
-
import { Lifecycle } from'react-router';
11
+
import { Lifecycle } from'react-router'
12
12
13
13
var Home =React.createClass({
14
14
@@ -18,18 +18,18 @@ var Home = React.createClass({
18
18
19
19
routerWillLeave(nextLocation) {
20
20
if (!this.state.isSaved)
21
-
return'Your work is not saved! Are you sure you want to leave?';
21
+
return'Your work is not saved! Are you sure you want to leave?'
22
22
},
23
23
24
24
// ...
25
25
26
-
});
26
+
})
27
27
```
28
28
29
29
If you need a [`routerWillLeave`](/docs/api/Lifecycle.md#routerwillleavenextlocation) hook in a deeply nested component, simply use the [`RouteContext`](/docs/api/RouteContext.md) mixin in your [route component](/docs/Glossary.md#routecomponent) to put the `route` in context.
0 commit comments