UNPKG

react-remote-props

Version:
22 lines (21 loc) 817 B
import { ComponentType, FC } from 'react'; export declare type PropsSetterParam<T> = Partial<T> | ((prev: T) => Partial<T>); export declare type PropsSetter<T> = (value: PropsSetterParam<T>) => void; /** * creates a wrapper around a component that allows to set props remotely * @param Component {ComponentType} the wanted component * @param initialProps {object} the props you want to inject * @returns array where the first value is the wrapped component and the second value is a function that setters the props. * @example ``` * const [Wrapper, setProps] = withProps(Button); * * // as component * <Wrapper /> * * // the setter * setProps({ * // props to change * }) * ``` */ export declare function remoteProps<T>(Component: ComponentType<T>, initialProps: Partial<T>): [FC, PropsSetter<T>];