그런데 그냥 문장만 변수에 저장하는 것이면 별로 유용하지 않을 것입니다. JSX가 유용한 이유 중의 하나는 javascript 표현식을 포함할 수 있다는 것입니다.
그래서 다음과 같은 것이 가능합니다.
JSX Represents Objects
설명
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
설명
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);
설명
// Note: this structure is simplified
const element = {
type: 'h1',
props: {
className: 'greeting',
children: 'Hello, world!'
}
};