2

I have a dispatch function called dispatchFetch that I need to pass from the parent component to the child component, and as I am using TypeScript, I need to declare the type in the child component.

My parent component contains the following code:

<ProductionSchedule 
    dispatchFetch={ dispatchFetch }
/>

The child component (ProductionSchedule) contains the following:

export interface Props {
    dispatchFetch: Dispatch;
};

TypeScript throwing the following error: Type 'Dispatch<Action>' is not assignable to type 'Dispatch<AnyAction>'.

Hovering over the prop, in the parent component I can see that the type is React.Dispatch<Action>, and in the child component the type is Dispatch<AnyAction>.

I have already explicitly set the type in the child to be <Dispatch>, and setting it to be Dispatch<Action> does not work either. How can I ensure that the types match?

SpencePro
  • 31
  • 1
  • 5

0 Answers0