type Category = {
id: number,
name: string,
products: number[]
}
type Items = {
[key: string]: any[]
}
export interface IGoods {
categories: Category[];
items: Items;
}
const App: React.FC = () => {
const [goods, setGoods] = useState<IGoods | object>({});
useEffect(() => {
fetch("https://delivery-f1999-default-rtdb.firebaseio.com/goods.json")
.then((data) => data.json())
.then((data) => setGoods(data))
}, [])
return (
<>
<Categories categories={goods.categories}/>
</>
);
};
Пытаюсь в компонент Categories передать категории, но ошибка - Property 'categories' does not exist on type 'object | IGoods'