From fd4742e0f6bea198e6f728962e1bc62d69fa24ff Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 02:53:44 +0900 Subject: [PATCH] feat : :lm command (by cd 'station') --- source/component/ListShop.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/source/component/ListShop.js b/source/component/ListShop.js index fd7efef..b9f4cf5 100644 --- a/source/component/ListShop.js +++ b/source/component/ListShop.js @@ -6,17 +6,21 @@ import EachShop from './EachShop.js'; import shoplist from '../examples/shoplist.js'; const ListShop = ({shops, setShops, setType}) => { - let first = 0; - let last = 3; const [confirmCommand, setConfirmCommand] = useState(''); + const [shop, setShop] = useState(shops.slice(0, 3)); + const [endMessage, setEndMessage] = useState(false); const loadMore = () => { - setShops([...shops, ...shoplist.slice(first + 3, last + 3)]); + setShop([...shop, ...shops.slice(shop.length, shop.length + 1)]); + + if (shops.length === shop.length) { + setEndMessage(true); + } }; return ( <> - {shops.length === 0 ? ( + {shop.length === 0 ? ( Status code: 404 검색 결과가 없습니다. @@ -25,14 +29,20 @@ const ListShop = ({shops, setShops, setType}) => { {'['} - {shops.map((data, index) => ( - - ))} + {shop.length !== 0 ? ( + shop.map((data, index) => ( + + )) + ) : ( + 리스트가 없습니다. + )} {']'} )} - + + {endMessage ? '더 이상 불러올 리스트가 없습니다' : ''} + @@ -42,7 +52,7 @@ const ListShop = ({shops, setShops, setType}) => { :q - quit / - :lm - load more reviews + :lm - load more store