common syntex
interface Props{
num: number;
}
num 값이 양수면 붉은색, 음수면 파란색, 0이면 초록색으로 표시
function IfComponent({num}:Props){
if(num > 0){
return(
<h1 style={{color: 'red'}}>{num}</h1>
);
}
if(num < 0){
return(
<h1 style={{color: 'blue'}}>{num}</h1>
);
}
return(
<h1 style={{color: 'green'}}>{num}</h1>
);
}
num 값이 양수면 붉은색, 음수면 파란색, 0이면 초록색으로 표시
function TreeTermComponent({num}:Props){
return(
<h1 style={{color: num > 0 ? 'red' : num <0 ? 'blue' : 'green'}}>{num}</h1>
)
}
num이 짝수일때만 렌더링
function LogicComponent({num}: Props){
return (
<h1>num: {(num % 2 === 0) && num}</h1>
)
}