Skip to content

Commit b8b9cde

Browse files
committed
Document confirming navigation with ES6 classes
1 parent d28036b commit b8b9cde

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/guides/advanced/ConfirmingNavigation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ const Home = React.createClass({
2626
})
2727
```
2828

29+
If you are using ES6 classes for your components, you can use [react-mixin](https://github.com/brigand/react-mixin) to add the `Lifecycle` mixin to your component.
30+
31+
```js
32+
import reactMixin from 'react-mixin'
33+
import { Lifecycle } from 'react-router'
34+
35+
class Foo extends Component { /* ... */ }
36+
reactMixin(Foo.prototype, Lifecycle)
37+
38+
// or
39+
40+
@reactMixin.decorate(Lifecycle)
41+
class Bar extends Component { /* ... */ }
42+
```
43+
2944
If you need a [`routerWillLeave`](/docs/API.md#routerwillleavenextlocation) hook in a deeply nested component, simply use the [`RouteContext`](/docs/API.md#routecontext-mixin) mixin in your [route component](/docs/Glossary.md#routecomponent) to put the `route` in context.
3045

3146
```js

0 commit comments

Comments
 (0)