source: imaps-frontend/node_modules/react-universal-interface/src/hookToRenderProp.ts@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 574 bytes
Line 
1import {FC} from 'react';
2import render from './render';
3
4export type MapPropsToArgs<Props extends {}, Args extends any[]> = (props: Props) => Args;
5export type CreateRenderProp = <Props extends {}, Args extends any[], State extends any>(hook: (...args: Args) => State, mapPropsToArgs?: MapPropsToArgs<Props, Args>) => FC<Props>;
6
7const defaultMapPropsToArgs = props => [props];
8
9const hookToRenderProp: CreateRenderProp = (hook, mapPropsToArgs = defaultMapPropsToArgs as any) =>
10 props => render(props, hook(...mapPropsToArgs(props)));
11
12export default hookToRenderProp;
Note: See TracBrowser for help on using the repository browser.