From a96e2ebfbce4de3216664f57dff79097c2b482dd Mon Sep 17 00:00:00 2001 From: giho Date: Fri, 2 Aug 2024 06:54:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=B1=84=EB=84=90=20=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EA=B0=80=20=EC=9E=88=EB=8A=94=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=B1=84=EB=84=90=20=EB=B0=94=EA=BF=80?= =?UTF-8?q?=EC=8B=9C=20=ED=94=8C=EB=A0=88=EC=9D=B4=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EA=B0=80=20=EC=95=88=EB=B6=88=EB=9F=AC=EC=99=80?= =?UTF-8?q?=EC=A7=80=EB=8A=94=20=ED=98=84=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/services/channel.ts | 2 +- src/pages/Main/Channel/Channel.hook.tsx | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/apis/services/channel.ts b/src/apis/services/channel.ts index 6b795a6..3f76796 100644 --- a/src/apis/services/channel.ts +++ b/src/apis/services/channel.ts @@ -13,7 +13,6 @@ export const getAllchannelLists = async () => { export const getChannelById = async (channelId: string | undefined) => { try { const response = await axiosInstanceWithToken.get(`/channels/${channelId}`); - console.log('response:', response.data); return response.data; } catch (error) { console.error(error); @@ -76,6 +75,7 @@ export const unsubscribeChannel = async (channelId: string, userId: string | und export const getMusicsByChannelId = async (channelId: string | undefined) => { try { const response = await axiosInstanceWithToken.get(`/channels/${channelId}/musics`); + console.log('musiclist', response.data); return response.data; } catch (e) { console.error(e); diff --git a/src/pages/Main/Channel/Channel.hook.tsx b/src/pages/Main/Channel/Channel.hook.tsx index fb1b7e4..0561cd3 100644 --- a/src/pages/Main/Channel/Channel.hook.tsx +++ b/src/pages/Main/Channel/Channel.hook.tsx @@ -13,7 +13,7 @@ export default function useChannel() { const { setChannelId } = useChannelIdStore(); const [musicList, setMusicList] = useState([]); const { music: currentMusic, setMusic, resetMusic } = useMusicStore(); - const { data, isLoading, isError } = useGetMusicsByChannelId(channelId); + const { data: musicListData, isLoading, isError, refetch } = useGetMusicsByChannelId(channelId); const [personalTap, setPersonalTap] = useState([ { name: 'Player', value: 0, isFocused: false }, { name: 'List', value: 1, isFocused: true }, @@ -49,15 +49,17 @@ export default function useChannel() { }; useEffect(() => { - if (data) { - setMusicList(data); - setChannelId(channelId); + if (channelId) { + refetch(); } + }, [refetch, channelId]); - return () => { - resetMusic(); - }; - }, [data, channelId]); + useEffect(() => { + if (musicListData) { + setMusicList(musicListData); + setChannelId(channelId); + } + }, [musicListData]); return { musicList, From ce8499737c1dc6f086e5e7ce0ba66aac5fa41125 Mon Sep 17 00:00:00 2001 From: giho Date: Fri, 2 Aug 2024 06:56:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20console.log=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/services/channel.ts | 1 - src/apis/services/user.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/apis/services/channel.ts b/src/apis/services/channel.ts index 3f76796..d13b9f0 100644 --- a/src/apis/services/channel.ts +++ b/src/apis/services/channel.ts @@ -75,7 +75,6 @@ export const unsubscribeChannel = async (channelId: string, userId: string | und export const getMusicsByChannelId = async (channelId: string | undefined) => { try { const response = await axiosInstanceWithToken.get(`/channels/${channelId}/musics`); - console.log('musiclist', response.data); return response.data; } catch (e) { console.error(e); diff --git a/src/apis/services/user.ts b/src/apis/services/user.ts index 78060ec..27dd213 100644 --- a/src/apis/services/user.ts +++ b/src/apis/services/user.ts @@ -16,7 +16,6 @@ export const updateUser = async (userId: string | undefined, user: FormData) => export const getMyChannelList = async (userId: string | undefined) => { try { const response = await axiosInstanceWithToken.get(`/users/myChannels/${userId}`); - console.log(response.data); return response.data; } catch (error) { console.error(error);