Skip to content

MapDispatchToProps shorthand #205

Closed
Closed
@Vanuan

Description

@Vanuan

Is there a solution for mapDispatchToProps shorthand syntax?

interface IProps {
  action: () => void;
}

const MyComponent = ({ action }: IProps): JSX.Element => (
  <div onClick={action}>my component</div>
);

const action = actionCreator<null>('SOME_ACTION'); // bound to dispatch

connect(null, { action })(MyComponent);

I'm getting this error:

Type 'ActionCreator<void>' is not assignable to type '() => void'.  TS2769

Is there a way to fix it without changing prop types of MyComponent?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions