inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

장재호님의 게시글

장재호 장재호

@jangjaeko459300

수강평 작성수
-
평균평점
-

게시글 3

질문&답변

use effect 부분에서 에러가나는 건지요...

import React ,{ useEffect , useState } from 'react' import axios from 'axios' ; import ProductImage from './Sections/ProductImage' ; import ProductInfo from './Sections/ProductInfo' ; import { Row , Col } from 'antd' ; import { useDispatch } from 'react-redux' ; import { addToCart } from '../../../_actions/user_actions' ; function DetailProductPage ( props ) { const productId = props . match . params . productId const dispatch = useDispatch const [ Product , setProduct ] = useState ({}) useEffect (() => { axios . get ( `/api/product/products_by_id?id= ${ productId } &type=single` ) . then ( response => { if ( response . data . success ){ setProduct ( response . data . product [ 0 ]) } else { alert ( '상세 정보 가져오기를 실패했습니다.' ) } }) },[] ) const addToCartHandler = ( productId ) => { dispatch ( addToCart ( productId )) } return ( div style = { { widht : '100%' , padding : '3rem 4rem' } } > div style = { { display : 'flex' , justifyContent : 'center' } } > h1 > { Product . title } h1 > div > br /> Row gutter = { [ 16 , 16 ] } > Col lg = { 12 } sm = { 24 } > { /* Product image */ } ProductImage addToCart = { addToCartHandler } detail = { Product } /> Col > Col lg = { 12 } sm = { 24 } > { /* Product Info */ } ProductInfo detail = { Product } /> Col > Row > div > ) } export default DetailProductPage github에 올려주신 자료 보고 수정했는데 똑같은 에러가 나네요 ㅠ

좋아요수
0
댓글수
3
조회수
461