Skip to content

Commit d1719b5

Browse files
committed
Avoid using componentWillMount.
See facebook/react#7671
1 parent eb60e79 commit d1719b5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ export default class KintoAdmin extends Component {
1919
plugins: [],
2020
}
2121

22-
componentWillMount() {
23-
const {plugins, settings} = this.props;
22+
constructor(props) {
23+
super(props);
24+
25+
const {plugins, settings} = props;
2426
this.store = configureStore({settings}, plugins);
2527
syncHistoryWithStore(hashHistory, this.store);
2628

29+
// Restore saved session, if any
2730
const session = loadSession();
2831
if (session) {
2932
this.store.dispatch(sessionActions.setup(session));
@@ -33,15 +36,15 @@ export default class KintoAdmin extends Component {
3336
render() {
3437
const {store} = this;
3538
const {plugins} = this.props;
36-
const registerPlugins = plugins.map(plugin => plugin.register(this.store));
39+
const registerPlugins = plugins.map(plugin => plugin.register(store));
3740

3841
function onRouteUpdate() {
3942
const {params, location} = this.state;
4043
store.dispatch(routeActions.routeUpdated(params, location));
4144
}
4245

4346
return (
44-
<Provider store={this.store}>
47+
<Provider store={store}>
4548
<Router history={hashHistory} onUpdate={onRouteUpdate}>
4649
{getRoutes(this.store, registerPlugins)}
4750
</Router>

0 commit comments

Comments
 (0)