File size: 336 Bytes
1e92f2d
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
const defaultMapPropsToArgs = (props) => [props];

export default function createRenderProp(hook, mapPropsToArgs = defaultMapPropsToArgs) {
  return function RenderProp(props) {
    const state = hook(...mapPropsToArgs(props));
    const { children, render = children } = props;
    return render ? render(state) || null : null;
  };
}