Search code examples
reactjsredux-toolkit

Type of dispatch result in redux toolik


I'm using the base CRA-Redux template

npx create-react-app my-app --template redux-typescript

Full code can found here

What I need to do is to pass a dispatch result as callback to parent component. But I don't know which type should be the dispatchResult. Can you help me with this issue?

enter image description here


Solution

  • One of the possible solutions is to use ReturnType hack

    onClick: ({dispatchResult}: {
      dispatchResult: ReturnType<ReturnType<typeof incrementAsync>>;
    }) => void;