recompose: Support OuterProps on withState enhancer (#27263)

* Support OuterProps on withState enhancer

Without this, any outer prop types are not handed into the component.

* Add tests withState with explicit outer types
This commit is contained in:
Paul Sachs 2018-07-20 21:15:13 -04:00 committed by Wesley Wigham
parent b92d9cfc1f
commit cd23add574
2 changed files with 10 additions and 1 deletions

View File

@ -141,7 +141,7 @@ declare module 'recompose' {
stateUpdaterName: TStateUpdaterName,
initialState: TState | mapper<TOutter, TState>
): InferableComponentEnhancerWithProps<
stateProps<TState, TStateName, TStateUpdaterName>,
TOutter & stateProps<TState, TStateName, TStateUpdaterName>,
TOutter
>;

View File

@ -256,6 +256,15 @@ function testWithState() {
const rendered2 = (
<Enhanced2 title="foo" />
);
// We can also actually provide the generic necessary
const enhancer3 = withState<OutterProps, number, "count", "setCount">("count", "setCount", 1);
const Enhanced3 = enhancer3(props => {
return <div>{props.title}</div>;
});
const rendered3 = (
<Enhanced3 title="foo" />
);
}
function testWithStateHandlers() {