/
index.jsx
38 lines (32 loc) · 951 Bytes
/
index.jsx
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
import { bindActionCreators } from 'redux';
import { connectAdvanced } from 'react-redux';
import shallowEqual from 'shallowequal';
import { get } from 'lodash/object';
import { docgenRequest } from 'state/docgens';
import PropTypesPage from './PropTypesPage';
export default connectAdvanced((dispatch) => {
let result;
const actions = bindActionCreators({ docgenRequest }, dispatch);
return (state, props) => {
const {
match: {
params: { component, section },
},
} = props;
const { toolbarTitle } = state.drawer;
const ids = ['docgens', section, component].filter(id => !!id);
const docgens = get(state, ids.join('.'), null);
const nextResult = {
component,
section,
docgens,
toolbarTitle,
mobile: state.media.mobile,
...actions,
};
if (!shallowEqual(result, nextResult)) {
result = nextResult;
}
return result;
};
})(PropTypesPage);