2019-01-03 17:14:25 +03:00
|
|
|
import 'devui/lib/presets';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import configureStore from './store/configureStore';
|
|
|
|
import { CONNECT_REQUEST } from './constants/socketActionTypes';
|
|
|
|
import App from './containers/App';
|
|
|
|
|
|
|
|
class Root extends Component {
|
2020-08-01 21:21:04 +03:00
|
|
|
UNSAFE_componentWillMount() {
|
2019-01-03 17:14:25 +03:00
|
|
|
configureStore((store, preloadedState) => {
|
|
|
|
this.store = store;
|
|
|
|
store.dispatch({
|
|
|
|
type: CONNECT_REQUEST,
|
2020-08-08 23:26:39 +03:00
|
|
|
options: preloadedState.connection || this.props.socketOptions,
|
2019-01-03 17:14:25 +03:00
|
|
|
});
|
|
|
|
this.forceUpdate();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (!this.store) return null;
|
|
|
|
return (
|
|
|
|
<Provider store={this.store}>
|
|
|
|
<App {...this.props} />
|
|
|
|
</Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Root.propTypes = {
|
|
|
|
socketOptions: PropTypes.shape({
|
|
|
|
hostname: PropTypes.string,
|
|
|
|
port: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
|
|
autoReconnect: PropTypes.bool,
|
2020-08-08 23:26:39 +03:00
|
|
|
secure: PropTypes.bool,
|
|
|
|
}),
|
2019-01-03 17:14:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Root;
|