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 | |
---|
1 | import {FC} from 'react';
|
---|
2 | import render from './render';
|
---|
3 |
|
---|
4 | export type MapPropsToArgs<Props extends {}, Args extends any[]> = (props: Props) => Args;
|
---|
5 | export type CreateRenderProp = <Props extends {}, Args extends any[], State extends any>(hook: (...args: Args) => State, mapPropsToArgs?: MapPropsToArgs<Props, Args>) => FC<Props>;
|
---|
6 |
|
---|
7 | const defaultMapPropsToArgs = props => [props];
|
---|
8 |
|
---|
9 | const hookToRenderProp: CreateRenderProp = (hook, mapPropsToArgs = defaultMapPropsToArgs as any) =>
|
---|
10 | props => render(props, hook(...mapPropsToArgs(props)));
|
---|
11 |
|
---|
12 | export default hookToRenderProp;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.