Skip to content
Snippets Groups Projects
Commit 49fe53ff authored by nahyun's avatar nahyun
Browse files

again correction

parent 41f5fd2b
No related branches found
No related tags found
No related merge requests found
Pipeline #8483 passed
import React from 'react';
//import React from 'react';
import React, { useEffect } from 'react';
import MusicList from './MusicList';
import music_list from './data';
import { Box, Tabs, Tab, Typography, AppBar, CssBaseline } from '@mui/material';
......@@ -15,6 +17,17 @@ export default function App() {
const handleTabChange = (event, newValue) => {
setCurrentTab(newValue);
}
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)
......@@ -114,6 +127,8 @@ export default function App() {
collectionName: item.collectionName,
collectionViewUrl: item.collectionViewUrl
}
)
.then((response) => {
console.log(response.data);
......
......@@ -3,23 +3,25 @@ import { Typography } from '@mui/material';
import MusicList from './MusicList';
import axios from 'axios';
import React, { useEffect } from 'react';
import App from './App';
const Favorites = ({ list, onLike }) => {
const Favorites = ({ list, onLike, setFavorites }) => {
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);
// });
// }, []);
return (
<React.Fragment>
<MusicList list={list} onLike={onLike} />
{/* <App setFavorites={setFavorites} /> */}
</React.Fragment>
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment