score:0

Accepted answer

{ cats: any; addcat: (cat: any) => void; } doesn't equal { id: number, idparent: number, description: string }

additional notes:

  • cat should be type - structcat
  • cats should be type - array of structcat
  • default context shouldn't be null if it can be avoided or isn't really a valid value for the purpose.
  • addcat should be addcat - it's good practice to only capitalize the first letter of react component names
interface icatcontext {
 cats: structcat[];
 addcat: (cat: structcat) => void;
}

createcontext<icatcontext>({
 cats: [],
 addcat: (_)=>{}
})

Related Query

More Query from same tag