diff --git a/pages/Karya.tsx b/pages/Karya.tsx index 9d945d0..6696fec 100644 --- a/pages/Karya.tsx +++ b/pages/Karya.tsx @@ -357,6 +357,16 @@ export const Karya = () => { setActiveSlide(0); }, [selectedId]); + // CRITICAL: Clear social states when switching posts to prevent showing wrong comments/likes + useEffect(() => { + // Reset to empty states when selectedId changes + setLikesCount(0); + setIsLiked(false); + setComments([]); + setNewComment(''); + setIsSubmittingComment(false); + }, [selectedId]); + const handleToggleLike = async () => { if (!user || !selectedId) { alert('Silakan login untuk menyukai karya ini.'); diff --git a/pages/Profile.tsx b/pages/Profile.tsx index 7166252..fd3f17d 100644 --- a/pages/Profile.tsx +++ b/pages/Profile.tsx @@ -248,6 +248,16 @@ export const Profile = () => { } }, [socialData]); + // CRITICAL: Clear social states when switching posts to prevent showing wrong comments/likes + useEffect(() => { + // Reset to empty states when selectedId changes + setLikesCount(0); + setIsLiked(false); + setComments([]); + setNewComment(''); + setIsSubmittingComment(false); + }, [selectedId]); + const handleToggleLike = async () => { if (!user || !selectedId) return; const prevLiked = isLiked;