-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
42 lines (35 loc) · 1.13 KB
/
Copy pathApp.js
File metadata and controls
42 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react';
import AppStyles from './resources/less/App.less';
import Navigation from './src/containers/Navigation';
import Modal from './src/components/Modal';
class App extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
const nextIsModal = this.isModalRoute(nextProps);
const routeTypeChanged = this.isModalRoute(this.props) !== nextIsModal;
this.previousChildren = nextIsModal && routeTypeChanged ? this.props.children : this.previousChildren;
}
isModalRoute(props) {
const { location } = props;
const { query } = location;
return Boolean(query && query.modal);
}
render() {
const isModal = this.isModalRoute(this.props);
const modalView = isModal ? (<Modal {...this.props} isOpen = {isModal}>{this.props.children}</Modal>) : undefined;
return (
<div className="ri-app-container">
<Navigation />
<div className = "ri-content">
{isModal ? this.previousChildren : this.props.children}
</div>
{modalView}
</div>
);
}
}
export default App;