2018-02-07 19:06:07 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2016-05-18 19:37:59 +02:00
|
|
|
import { connect } from 'react-redux';
|
2016-06-23 00:36:04 +02:00
|
|
|
import DevTools from './components/DevTools';
|
2016-12-16 00:43:58 +01:00
|
|
|
import { setPreviousPath } from '../IDE/actions/ide';
|
2016-05-18 19:37:59 +02:00
|
|
|
|
2018-08-24 23:41:23 +02:00
|
|
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
|
|
|
|
2016-05-18 19:37:59 +02:00
|
|
|
class App extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
2016-06-24 00:29:55 +02:00
|
|
|
this.state = { isMounted: false };
|
2016-06-23 00:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2016-06-27 23:22:54 +02:00
|
|
|
this.setState({ isMounted: true }); // eslint-disable-line react/no-did-mount-set-state
|
2019-03-28 21:53:22 +01:00
|
|
|
document.body.className = 'light';
|
2016-05-18 19:37:59 +02:00
|
|
|
}
|
|
|
|
|
2016-12-16 00:43:58 +01:00
|
|
|
componentWillReceiveProps(nextProps) {
|
2019-08-24 13:28:21 +02:00
|
|
|
const locationWillChange = nextProps.location !== this.props.location;
|
|
|
|
const shouldSkipRemembering = nextProps.location.state && nextProps.location.state.skipSavingPath === true;
|
|
|
|
|
|
|
|
if (locationWillChange && !shouldSkipRemembering) {
|
2016-12-16 00:43:58 +01:00
|
|
|
this.props.setPreviousPath(this.props.location.pathname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-18 19:37:59 +02:00
|
|
|
render() {
|
|
|
|
return (
|
2016-09-14 18:46:54 +02:00
|
|
|
<div className="app">
|
2018-08-24 23:41:23 +02:00
|
|
|
{this.state.isMounted && !window.devToolsExtension && __process.env.NODE_ENV === 'development' && <DevTools />}
|
2016-06-24 00:29:55 +02:00
|
|
|
{this.props.children}
|
2016-05-18 19:37:59 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 22:14:26 +02:00
|
|
|
App.propTypes = {
|
2017-02-22 20:29:35 +01:00
|
|
|
children: PropTypes.element,
|
2016-12-16 00:43:58 +01:00
|
|
|
location: PropTypes.shape({
|
|
|
|
pathname: PropTypes.string
|
2017-02-22 20:29:35 +01:00
|
|
|
}).isRequired,
|
2016-12-16 00:43:58 +01:00
|
|
|
setPreviousPath: PropTypes.func.isRequired,
|
2016-06-27 22:14:26 +02:00
|
|
|
};
|
|
|
|
|
2017-02-22 20:29:35 +01:00
|
|
|
App.defaultProps = {
|
|
|
|
children: null
|
|
|
|
};
|
|
|
|
|
2016-12-16 00:43:58 +01:00
|
|
|
export default connect(() => ({}), { setPreviousPath })(App);
|