Skip to content

Typings for dispatch props #51

Closed
Closed
@sample-usr

Description

@sample-usr

Hi,
I'm trying to provide typings for my actions inside a connected component.

interface IDispatchProps {
  setName: typeof setName // where setName is an imported action
}

Given that the action is defined as:

export const setName = actionCreator<string>('SET_NAME');

The idea is to use those typings when defining mapDispatchToProps:

const mapDispatchToProps = (dispatch): IDispatchProps => ({
  setName: (name:string) =>dispatch(setName(name))
})

However I get an error about the typings being incompatible. Is there a way to get the type of that action?

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