Skip to content

Commit

Permalink
Avoid using componentWillMount.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Sep 7, 2016
1 parent eb60e79 commit d1719b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ export default class KintoAdmin extends Component {
plugins: [],
}

componentWillMount() {
const {plugins, settings} = this.props;
constructor(props) {
super(props);

const {plugins, settings} = props;
this.store = configureStore({settings}, plugins);
syncHistoryWithStore(hashHistory, this.store);

// Restore saved session, if any
const session = loadSession();
if (session) {
this.store.dispatch(sessionActions.setup(session));
Expand All @@ -33,15 +36,15 @@ export default class KintoAdmin extends Component {
render() {
const {store} = this;
const {plugins} = this.props;
const registerPlugins = plugins.map(plugin => plugin.register(this.store));
const registerPlugins = plugins.map(plugin => plugin.register(store));

function onRouteUpdate() {
const {params, location} = this.state;
store.dispatch(routeActions.routeUpdated(params, location));
}

return (
<Provider store={this.store}>
<Provider store={store}>
<Router history={hashHistory} onUpdate={onRouteUpdate}>
{getRoutes(this.store, registerPlugins)}
</Router>
Expand Down

0 comments on commit d1719b5

Please sign in to comment.