안녕하세요, 리덕스를 통해서 좋아요 기능구현을 해보고 있는데 디스패치와 충돌이 나는것 같습니다.
const CourseReviewItems = ({ coursePostReviewPosts, post, currentIndex, pageId, postId }) => { const starRendering = (star) => { const stars = []; for (let i = 0; i ) } for (let i = 0; i ) } return stars } return ( {starRendering(coursePostReviewPosts.point)} {coursePostReviewPosts.point} {coursePostReviewPosts.User.name}{`(${coursePostReviewPosts.User.id})`} · {coursePostReviewPosts.date} {coursePostReviewPosts.content} ); }; const Heart = ({ pageId, id, currentIndex, postId }) => { const dispatch = useDispatch(); const { coursePosts } = useSelector((state) => state.coursePost); const [clicked, setClicked] = useState(false); const heart = coursePosts[currentIndex].CourseReview[id].heart; console.log(clicked) const onClickHeart = () => { // if (!clicked) { // dispatch(coursePostActions.clickCourseReviewHeart({ pageId, postId })) // console.log("true") // } else { // dispatch(coursePostActions.clickCourseReviewHeartAgain({ pageId, postId })) // console.log("false") // } setClicked((p) => !p); console.log("dfdf", clicked) dispatch(coursePostActions.clickCourseReviewHeart({ pageId, postId })) } console.log(clicked) return ( {heart} ); }; export default CourseReviewItems;