diff --git a/.gitignore b/.gitignore index 927d17b..215a7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* - +#webstorm +.idea/ diff --git a/src/components/ProductDetail.js b/src/components/ProductDetail.js index 885919a..6a178f9 100644 --- a/src/components/ProductDetail.js +++ b/src/components/ProductDetail.js @@ -1,30 +1,59 @@ import React from "react"; +import Reviews from "./Reviews"; -function ProductDetail(props) { - const {name,description,rating,imgUrl} = props.product; - const stars = []; - for (let i = 0; i < rating; i++) { - stars.push(); + +class ProductDetail extends React.Component { + constructor(props) { + super(props); + this.state = { + visible: false + }; } - return ( -
{description} -
-15 reviews
-- {stars} -
+ buttonClick = () => { + this.setState(prevState => ({ + visible: !prevState.visible + })); + console.log(this.state.visible); + }; + + render() { + + const {name, description, rating, imgUrl} = this.props.product; + const stars = []; + for (let i = 0; i < rating; i++) { + stars.push(); + } + const reviewIt = this.props.product.reviews.map((r) => { + if (this.state.visible) { + return{description} +
++ {stars} +
+