mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
14 lines
373 B
TypeScript
14 lines
373 B
TypeScript
const defaultMapPropsToArgs = props => [props];
|
|
|
|
const createRenderProp = (hook, mapPropsToArgs = defaultMapPropsToArgs) => {
|
|
const RenderProp = props => {
|
|
const state = hook(...mapPropsToArgs(props));
|
|
const { children, render = children } = props;
|
|
return render ? render(state) || null : null;
|
|
};
|
|
|
|
return RenderProp;
|
|
};
|
|
|
|
export default createRenderProp;
|