-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocs.js
More file actions
31 lines (27 loc) · 911 Bytes
/
Copy pathDocs.js
File metadata and controls
31 lines (27 loc) · 911 Bytes
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
import React from 'react';
import Navigation from './Navigation';
import ComponentPage from './ComponentPage';
import componentData from '../../config/componentData';
export default class Docs extends React.Component {
constructor(props) {
super(props);
this.state = {
route: window.location.hash.substr(1)
};
}
componentDidMount() {
window.addEventListener('hashchange', () => {
this.setState({route: window.location.hash.substr(1)})
})
}
render() {
const {route} = this.state;
const component = route ? componentData.filter( component => component.name === route)[0] : componentData[0];
return (
<div>
<Navigation components={componentData.map(component => component.name)} />
<ComponentPage component={component} />
</div>
)
}
}