{reviewList.map((review, index) => {
const endDate = new Date(review.endDate);
const curmonth = endDate.getMonth();
let premonth = -1
let n = 0
console.log("title: ", review.title, "month: ", curmonth, premonth, "x: ", Math.cos((n * 20 % 360) * (Math.PI / 180)) * (60 + 35 * curmonth))
if (curmonth === premonth) {
n += 1
} else (
n = 0
)
premonth = endDate.getMonth();
return (
<PlanetWrapper
key={index}
src={review.bookImage}
m={curmonth}
n={n}
/>
);
})}
이렇게 작성했는데 콘솔에 찍어보니 premonth와 n이 바뀌지 않았다.
당연함
map 돌 때마다 새로 설정되기 때문
댓글