react-redux-isomorphic
Version:
Set of utilities for creating isomorphic applications using react-redux
30 lines (29 loc) • 1.79 kB
TypeScript
import { Component } from 'react';
import type { ComponentType, ReactElement } from 'react';
import type { DefaultLoadParams, SingleState } from './types';
export declare type ContextResolverProps<BaseProps, IsomorphicContext, IsomorphicError, LoadParams = DefaultLoadParams> = {
component: ComponentType<BaseProps & {
isomorphic: SingleState<IsomorphicContext, IsomorphicError>;
}>;
componentProps: BaseProps;
isomorphicId: string;
isomorphic: SingleState<IsomorphicContext, IsomorphicError>;
loadParams: LoadParams;
getContext: (loadParams: LoadParams, baseProps: BaseProps) => IsomorphicContext | Promise<IsomorphicContext>;
shouldReload?: (prevProps: BaseProps, nextProps: BaseProps) => boolean;
loadContext: (isomorphicId: string) => void;
loadContextSuccess: (isomorphicId: string, isomorphicContext: IsomorphicContext) => void;
loadContextError: (isomorphicId: string, isomorphicError: IsomorphicError) => void;
destroy: (isomorphicId: string) => void;
};
export declare class ContextResolver<BaseProps, IsomorphicContext, IsomorphicError, LoadParams = DefaultLoadParams> extends Component<ContextResolverProps<BaseProps, LoadParams, IsomorphicContext, IsomorphicError>> {
constructor(props: ContextResolverProps<BaseProps, LoadParams, IsomorphicContext, IsomorphicError>);
componentDidUpdate(oldProps: ContextResolverProps<BaseProps, LoadParams, IsomorphicContext, IsomorphicError>): Promise<void>;
componentWillUnmount(): void;
init(): Promise<IsomorphicContext>;
requestContext(): Promise<IsomorphicContext>;
destroy(): void;
render(): ReactElement;
}
declare const IsomorphicWrapper: ComponentType<ContextResolverProps<unknown, unknown, unknown, unknown>>;
export default IsomorphicWrapper;