mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
[react-redux] extended ThunkActionCreator testsuite to check all overloads
This commit is contained in:
@@ -120,12 +120,61 @@ function MapDispatchWithThunkActionCreators() {
|
||||
}
|
||||
class TestComponent extends React.Component<TestComponentProps> {}
|
||||
|
||||
const Test = connect(
|
||||
null,
|
||||
({ simpleAction, thunkAction }),
|
||||
)(TestComponent);
|
||||
const mapStateToProps = ({ foo }: { foo: string }) => ({ foo });
|
||||
const mapDispatchToProps = { simpleAction, thunkAction };
|
||||
|
||||
const verify = <Test foo='bar' />;
|
||||
const Test1 = connect(null, mapDispatchToProps)(TestComponent);
|
||||
const Test2 = connect(mapStateToProps, mapDispatchToProps)(TestComponent);
|
||||
const Test3 = connect(
|
||||
null, mapDispatchToProps, null, { storeKey: 'somekey' }
|
||||
)(TestComponent);
|
||||
const Test4 = connect(
|
||||
mapStateToProps, mapDispatchToProps, null, { storeKey: 'somekey' }
|
||||
)(TestComponent);
|
||||
const verify = <div>
|
||||
<Test1 foo='bar' />;
|
||||
<Test2 />
|
||||
<Test3 foo='bar' />;
|
||||
<Test4 />
|
||||
</div>;
|
||||
}
|
||||
|
||||
function MapManualDispatchThatLooksLikeThunk() {
|
||||
interface OwnProps {
|
||||
foo: string;
|
||||
}
|
||||
interface TestComponentProps extends OwnProps {
|
||||
remove: (item: string) => () => object;
|
||||
}
|
||||
class TestComponent extends React.Component<TestComponentProps> {
|
||||
render() {
|
||||
return <div onClick={this.props.remove('someid')} />;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({ foo }: { foo: string }) => ({ foo });
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
remove(item: string) {
|
||||
return () => dispatch({ type: 'REMOVE_ITEM', item });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const Test1 = connect(null, mapDispatchToProps)(TestComponent);
|
||||
const Test2 = connect(mapStateToProps, mapDispatchToProps)(TestComponent);
|
||||
const Test3 = connect(
|
||||
null, mapDispatchToProps, null, { storeKey: 'somekey' }
|
||||
)(TestComponent);
|
||||
const Test4 = connect(
|
||||
mapStateToProps, mapDispatchToProps, null, { storeKey: 'somekey' }
|
||||
)(TestComponent);
|
||||
const verify = <div>
|
||||
<Test1 foo='bar' />;
|
||||
<Test2 />
|
||||
<Test3 foo='bar' />;
|
||||
<Test4 />
|
||||
</div>;
|
||||
}
|
||||
|
||||
function MapStateAndDispatchObject() {
|
||||
|
||||
Reference in New Issue
Block a user