Skip to content

Instantly share code, notes, and snippets.

@Joe1220
Created August 6, 2018 13:53
Show Gist options
  • Save Joe1220/5c2c33ecdc37be9c470fe5d06c889e95 to your computer and use it in GitHub Desktop.
Save Joe1220/5c2c33ecdc37be9c470fe5d06c889e95 to your computer and use it in GitHub Desktop.
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