typedefs for useState across components with object arrays
We have a
Parent and a Child component.
inside of parent we init the following state:
we want this state to be shared between our two components
inside of Parent we render a Child passing the state as props
inside of our Child component we define our props and eventually we may want to update the state.
Right now I am getting an trying to create a helper function in the parent component so I don't have do deal with the setState types, eg. in the child component
The current one I have looks like the following:
The problem is that I am getting a ts(2345) error, a type mismatch.
Argument of type '(prevState: { url: string; partNumber: number; }[]) => ({ url: string; partNumber: number; } | { url: string; partNumber: number; }[])[]' is not assignable to parameter of type 'SetStateAction<{ url: string; partNumber: number; }[]>'.1 Reply
Did you try ...urls?