@sourcebug/amos
Version:
A decentralized state manager for react
11 lines (10 loc) • 977 B
TypeScript
import { ComponentProps, ComponentType, ElementRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
import { Dispatch, Select } from './store';
export interface ConnectedProps {
dispatch: Dispatch;
}
export declare type ConnectedComponent<TOwnedProps, TMappedProps, C extends ComponentType<any>> = ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentProps<C>, keyof TMappedProps | keyof ConnectedProps> & TOwnedProps> & RefAttributes<ElementRef<C>>> & {
WrappedComponent: C;
};
export declare type Connector<TOwnedProps extends object = {}, TMappedProps extends object = {}> = <C extends ComponentType<Partial<ConnectedProps> & TMappedProps & ComponentProps<C>>>(Component: C) => ConnectedComponent<TOwnedProps, TMappedProps, C>;
export declare function connect<TMappedProps extends object = {}, TOwnedProps extends object = {}>(extractor?: (select: Select, ownedProps: TOwnedProps) => TMappedProps): Connector<TOwnedProps, TMappedProps>;