React.createElement()
React.createElement(type, [props], [...children])// 이 둘은 같은 속성을 가진 요소를 생성한다.
React.createElement(App, {className: 'newNode', children: 'text'})
React.createElement(App, {className: 'newNode'}, 'text') function App(props) {
return <div className={props.className}>{props.children}</div>
}
const app = React.createElement(App, {className: 'newNode', children: 'text'})// 위의 코드에서 객체 구조 분해 할당을 해보면
function App(props) {
// {className: 'newNode', children: 'text'}
const {className, children} = props
return <div className={className}>{children}</div>
}Last updated