interface Crumb {
title: string;
url: string;
}
interface Crumbies {
crumbsArray: Crumb[];
}
// component
const [breadcrumbs, setBreadcrumbs] = useState<Crumbies>([]);
I'm getting an error:
TS2345: Argument of type 'never[]' is not assignable to parameter of type 'Crumbies | (() => Crumbies)'. Type 'never[]' is not assignable to type '() => Crumbies'. Type 'never[]' provides no match for the signature '(): Crumbies'.
How to provide a correct typings for an empty array in useState hook?
UPDATE 1
const Breadcrumbs: React.FC<Crumbies> = ({ crumbsArray }) => {}
That's why i've created another interface Crumbies to wrap Crumb. Is there a better approach to this?