createElement

고명빈·2021년 5월 23일

리액트 함수 정리

목록 보기
1/3
  • 구조
React.createElement(component, props, ...children)

  • 매개 변수
  1. component

    • 문자열이나 리액트 컴포넌트
    • 문자열이면 HTML 태그에 해당하는 DOM 요소 생성
  2. props

    • 컴포넌트가 사용할 데이터(ex> style, className)
  3. children

    • 컴포넌트가 감싸고 있는 내부의 컴포넌트

  • 사용법
createElement(
	'div',
  	null,
  	createElement('p', null, 'hello'),
  	createElement('p', null, 'world'),
)

0개의 댓글