useEffect 사용시 주의해야 할 것들
·
React
자제해야 하는 케이스 Props에 기반한 상태 업데이트// 🚫 잘못된 사용function ProductCard({ price, quantity }) { const [total, setTotal] = useState(0); useEffect(() => { setTotal(price * quantity); }, [price, quantity]); return 총 가격: {total};}// ✅ 개선: 렌더링 중에 직접 계산function ProductCard({ price, quantity }) { const total = price * quantity; return 총 가격: {total};} Props를 State로 미러링// 🚫 잘못된 사용function..