forked from aces/EEG2BIDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewManager.js
49 lines (46 loc) · 1.02 KB
/
ViewManager.js
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
43
44
45
46
47
48
49
import React from 'react';
import {
HashRouter,
Routes,
Route,
} from 'react-router-dom';
// Components
import App from './App';
import Settings from './Settings';
/**
* ViewManager - the multiple windows manager.
* @param {object} props
* @return {JSX.Element}
*/
const ViewManager = (props) => {
/**
* Renders the React component.
* @return {JSX.Element} - React markup for component.
*/
return (
<HashRouter>
<div>
<Routes>
{/*<Route path='/' element={ViewManager.View}/>*/}
<Route path='/' exact element={<App/>}/>
<Route path='/settings' element={<Settings/>}/>
</Routes>
</div>
</HashRouter>
);
};
ViewManager.views = () => {
return {
app: <App/>,
settings: <Settings/>,
};
};
ViewManager.View = (props) => {
const name = props.location.search.substr(1);
const view = ViewManager.views()[name];
if (view == null) {
throw new Error('View \'' + name + '\' is undefined');
}
return view;
};
export default ViewManager;