Created
August 6, 2018 13:53
-
-
Save Joe1220/5c2c33ecdc37be9c470fe5d06c889e95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Link } from 'react-router-dom'; | |
const Main = props => { | |
if(props.products) { | |
return <RenderProducts products={props.products}/> | |
} else { | |
return <RenderLoading /> | |
} | |
} | |
const RenderProducts = props => { | |
return props.products.map((product) => { | |
return ( | |
<div className="product"> | |
<Link className="productImg" to={`/item/${product.id}`}><img src={product.image} alt="food"/></Link> | |
<div className="productName"> | |
<p className="productTitle">{product.name}</p> | |
</div> | |
<hr /> | |
<p className="productPrice">{product.price.toLocaleString()} 원</p> | |
</div> | |
); | |
}) | |
}; | |
const RenderLoading = props => ( | |
<div>Loading...</div> | |
); | |
export default Main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment