@orca-fe/hooks
Version:
React Hooks Collections
24 lines (23 loc) • 1.06 kB
TypeScript
type ControllableState<T, U> = {
[P in keyof T]: T[P];
} & {
[P in keyof U]-?: Exclude<U[P], undefined>;
} & Record<string, any>;
export declare const upperFirstKey: (str?: string) => string;
export declare const getPropListenerName: (key: string) => string;
export declare const getPropsListenerName: (props?: {}) => string[];
export declare const validateProps: (initProps: Record<string, any>, newProps?: Record<string, any>) => Record<string, any>;
/**
* 对比变化的属性,提取出需要变化的state(属性值为undefined)
*
* @param newProps
* @private
*/
export declare const getChangedState: <T extends Record<string, any>>(props: T, newProps?: Record<string, any>) => T;
export type ControllablePropsConfig = {
omitListener?: boolean;
autoOnChange?: boolean;
combineListener?: boolean;
};
export default function useControllableProps<T extends Record<string, any>, P extends Partial<T>>(props: T, initProps?: P, config?: ControllablePropsConfig): [ControllableState<T, P>, (props: Partial<P>) => any];
export {};