| Total Complexity | 0 |
| Complexity/F | 0 |
| Lines of Code | 21 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import React from 'react' |
||
| 2 | import { compose } from 'ramda' |
||
| 3 | |||
| 4 | import fromRenderProps from './fromRenderProps' |
||
| 5 | import setHocDisplayName from './setHocDisplayName' |
||
| 6 | import { stateToProps } from './stateToProps' |
||
| 7 | |||
| 8 | /** |
||
| 9 | * This function creates a HOC for connect the given global store context to the given Component. |
||
| 10 | * Only the props provided through the |
||
| 11 | * @param {React.Context} GlobalStoreContext The global store context |
||
| 12 | * @function |
||
| 13 | * @return connect HOC |
||
| 14 | */ |
||
| 15 | export const createConnect = GlobalStoreContext => mapStateToProps => Component => |
||
| 16 | compose( |
||
| 17 | setHocDisplayName('connect', Component), |
||
| 18 | fromRenderProps(GlobalStoreContext.Consumer, stateToProps(mapStateToProps)), // connect with consumer |
||
| 19 | React.memo // Do not unnessasary rerender |
||
| 20 | )(Component) |
||
| 21 |