[React] JSX
2022. 9. 26. 19:31ㆍWeb/React
JSX란?
JavaScript를 확장한 문법.
JSX에 표현식 포함하기
const name = 'Josh Perez';
const element = <h1>Hello, {name}</h1>;
JSX 속성 정의
어트리뷰트에 따옴표를 이용해 문자열 리터럴을 정의할 수 있다.
const element = <a href="https://www.reactjs.org"> link </a>;
const element = <img src={user.avatarUrl}></img>;
JSX로 자식 정의
const element = (
<div>
<h1>Hello!</h1>
<h2>Good to see you here.</h2>
</div>
);
'Web > React' 카테고리의 다른 글
| [React] 이벤트 처리하기 (0) | 2023.03.09 |
|---|---|
| [React] State (0) | 2023.03.01 |
| [React] Component와 Props (0) | 2022.09.26 |
| [React] 엘리먼트 렌더링 (0) | 2022.09.26 |