Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 27 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import React from 'react' |
||
2 | |||
3 | import setHocDisplayName from './setHocDisplayName' |
||
4 | |||
5 | const fromRenderProps = ( |
||
6 | RenderPropsComponent, |
||
7 | propsMapper, |
||
8 | renderPropName = 'children' |
||
9 | ) => BaseComponent => { |
||
10 | const baseFactory = React.createFactory(BaseComponent) |
||
11 | const renderPropsFactory = React.createFactory(RenderPropsComponent) |
||
12 | |||
13 | const FromRenderProps = ownerProps => |
||
14 | renderPropsFactory({ |
||
15 | [renderPropName]: (...props) => |
||
16 | baseFactory({ ...ownerProps, ...propsMapper(...props) }) |
||
17 | }) |
||
18 | |||
19 | if (process.env.NODE_ENV !== 'production') { |
||
20 | return setHocDisplayName('fromRenderProps', BaseComponent)(FromRenderProps) |
||
21 | } |
||
22 | |||
23 | return FromRenderProps |
||
24 | } |
||
25 | |||
26 | export default fromRenderProps |
||
27 |