fix(flux): fix types for createFunctional (#36023)

This commit is contained in:
Toru Kobayashi 2019-06-13 08:05:52 +09:00 committed by Ron Buckton
parent 324d049ad8
commit 37fa8e39d4
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ export function create<TProps, TState, TContext, TStatic>(base: Component<TProps
* This is a way to connect stores to a functional stateless view.
*/
export function createFunctional<TProps, TState>(
viewFn: (props: TProps) => React.ReactElement<TState>,
viewFn: (props: TState) => React.ReactElement<TState>,
getStores: (maybeProps?: TProps, maybeContext?: any) => Array<FluxStore<any>>,
calculateState: (prevState?: TState, maybeProps?: TProps, maybeContext?: any) => TState,
options?: RealOptions

View File

@ -65,14 +65,14 @@ const ContainerComponent3 = Container.create<Props, State>(CounterContainer, { w
<ContainerComponent3 a="string" b={false} />;
// Functional flux container with Store
const FunctionalContainerComponent = Container.createFunctional<Props, State>(
(props) => {
const FunctionalContainerComponent = Container.createFunctional(
(props: State) => {
return <div>
{props.a} {props.b}
{props.counter}
</div>;
},
() => [Store],
(prevState) => ({ counter: Store.getState() })
(props: Props) => [Store],
(prevState: State, props: Props) => ({ counter: Store.getState() })
);
<FunctionalContainerComponent a="string" b={true} />;
<FunctionalContainerComponent a="string" b={false} />;