정의
ex) const element = <h1>Hello, world!</h1>;
역할
ex)
React.createElement(
type,
[props],
[…children]
)createElement() -> xml/html코드를 javascript로 변환해주는 함수JSX를 사용한 코드
ex) const element = (
<h1 className=“greeting”>
Hello, world!
</h1>
)
JSX를 사용하지 않은 코드
ex) const element = React.createElement (
‘h1’,
{className: ‘greeting’},
‘Hello, world!’
)
React.createElement()의 결과로 아래와 같은 객체가 생성
ex) const element = {
type: ‘h1’,#엘리먼트 유형 : 태그명, 다른 리액트 컴포넌트
props:{ # 프롭스 : 속성
className:’greeting’,#엘리먼트가 포함하고 있는 자식 엘리먼트
children:’Hello, world!’
}
}
@때문에, 리액트에서 JSX를 쓰는 것이 필수는 아님