예를 들어서 아래 이런 함수에서 () => {} 중괄호를 하면 리턴이 필요하고
const Detail = (props) => {
return (
<div className="container">
<div className="row">
<div className="col-md-6">
<img
alt=""
src="https://codingapple1.github.io/shop/shoes1.jpg"
width="100%"
/>
</div>
<div className="col-md-6">
<h4 className="pt-5">{props.shoes[0].title}</h4>
<p>{props.shoes[0].content}</p>
<p>120000원</p>
<button className="btn btn-danger">주문하기</button>
</div>
</div>
</div>
);
};
이런식으로 중괄호 없이 ()=>() 이런 함수의 경우 return 이 없이도 작동하는데요
const Detail = (props) => (
<div className="container">
<div className="row">
<div className="col-md-6">
<img
alt=""
src="https://codingapple1.github.io/shop/shoes1.jpg"
width="100%"
/>
</div>
<div className="col-md-6">
<h4 className="pt-5">{props.shoes[0].title}</h4>
<p>{props.shoes[0].content}</p>
<p>120000원</p>
<button className="btn btn-danger">주문하기</button>
</div>
</div>
</div>
);
제가 궁금한건 return 이 있고 없고의 차이가 어떤점이 있을까요?
구글링 해본 결과 여러줄의 코드를 작성할때 중괄호를 사용해서 리턴값을 준다고 하는데
위의 두개 함수는 동일한 작동을 보이는거 같아서요ㅎㅎ
제가 너무 기초적인걸 질문한거 같아서 민망한데 궁금해서 질문드려봅니다ㅎㅎ