diff --git a/src/App.js b/src/App.js index d3825573be5af171c70c6abeb642327e97190bb0..d480591c2b2213b9e0028211bc7c93e3e2669077 100644 --- a/src/App.js +++ b/src/App.js @@ -18,16 +18,17 @@ export default function App() { setCurrentTab(newValue); } - useEffect(() => { - axios.get('/likes') - .then((response) => { - const data = response.data; - setFavorites(data); - }) - .catch((error) => { - console.error('Error:', error); - }); - }, []); + // useEffect(() => { + // axios.get('/likes') + // .then((response) => { + // const data = response.data; + // setFavorites(data); + // }) + // .catch((error) => { + // console.error('Error:', error); + // }); + // }, []); + //수정 - 버전1 // const handleOnLike = (item) => { // let value = favorites.find(it => it.collectionId == item.collectionId) @@ -200,8 +201,7 @@ export default function App() { <Box sx={{ borderBottom: 1, borderColor: 'divider' }}> - <Tabs value={currentTab} onChange={handleTabChange} aria-label="basic tabs" - centered> + <Tabs value={currentTab} onChange={handleTabChange} aria-label="basic tabs" centered> <Tab label="Search Music" value={0} /> <Tab label="Favorites" value={1} /> <Tab label="More Contents" value={2} /> diff --git a/src/favorites.js b/src/favorites.js index 873133d76c1f2babfbab73335eb58774b52af3c1..b4597461e4ff27e77ca50258be4fc93338ac6190 100644 --- a/src/favorites.js +++ b/src/favorites.js @@ -5,18 +5,19 @@ import axios from 'axios'; import React, { useEffect } from 'react'; import App from './App'; -const Favorites = ({ list, onLike, setFavorites }) => { - - // useEffect(() => { - // axios.get('/likes') - // .then((response) => { - // const data = response.data; - // setFavorites(data); - // }) - // .catch((error) => { - // console.error('Error:', error); - // }); - // }, []); +const Favorites = ({ list, onLike }) => { + const [Favorites, setFavorites] = React.useState([]); + + useEffect(() => { + axios.get('/likes') + .then((response) => { + const data = response.data; + setFavorites(data); + }) + .catch((error) => { + console.error('Error:', error); + }); + }, []); return ( <React.Fragment>