diff --git a/src/App.tsx b/src/App.tsx index 2cf5239da..63e76f109 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,27 +1,46 @@ -import React from 'react'; +import React, { useState } from 'react'; import './App.scss'; import { GoodsList } from './GoodsList'; -// import { getAll, get5First, getRed } from './api/goods'; -// or -// import * as goodsAPI from './api/goods'; +import { getAll, get5First, getRedGoods } from './api/goods'; +import { Good } from './types/Good'; -export const App: React.FC = () => ( -
-

Dynamic list of Goods

+export const App: React.FC = () => { + const [goods, setGoods] = useState([]); - + const fiveFirstArray = () => { + get5First().then(setGoods); + }; - + const redGoodsArray = () => { + getRedGoods().then(setGoods); + }; - + const fetchAllGoods = () => { + getAll().then(setGoods); + }; - -
-); + return ( +
+

Dynamic list of Goods

+ + + + + + + + +
+ ); +}; diff --git a/src/GoodsList.tsx b/src/GoodsList.tsx index ca92d7573..28b3ca72c 100644 --- a/src/GoodsList.tsx +++ b/src/GoodsList.tsx @@ -8,7 +8,7 @@ type Props = { export const GoodsList: React.FC = ({ goods }) => (