import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Router } from 'react-router';
import renderRoutes from 'utils/RouterConfig';
import { Provider } from 'mobx-react';
import 'styles/main.less';
import routes from './routes';
import i18n from './i18n';
class App extends Component {
static propTypes = {
rootStore: PropTypes.object,
history: PropTypes.object,
};
constructor(props) {
super(props);
this.state = { initDone: false };
}
componentDidMount() {
this.appLoadLocales();
}
appLoadLocales() {
const { loadLocales } = i18n;
loadLocales();
this.setState({ initDone: true });
}
render() {
const { rootStore, history } = this.props;
const { initDone } = this.state;
return (
initDone && (
<Provider rootStore={rootStore}>
<Router history={history}>{renderRoutes(routes)}</Router>
</Provider>
)
);
}
}
export default App;