jangjaeko459300
@jangjaeko459300
Reviews Written
-
Average Rating
-
Posts
Q&A
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
- 430
Q&A
use effect ๋ถ๋ถ์์ ์๋ฌ๊ฐ๋๋ ๊ฑด์ง์...
๋ฆฌ์กํธ ๋ฒ์ ์ 16.8.6 ์ ๋๋ค ใ
- 0
- 3
- 430
Q&A
๋ก๊ทธ์ธ,ํ์๊ฐ์ ๋ฒํผ์ ๋๋ฅด๋ฉด ์๋ฌ๊ฐ ๋น๋๋คใ
์ ๋ ๋๊ฐ์ ์๋ฌ๊ฐ ๋๋ค์ ใ ใ
- 0
- 1
- 170




