개발/react
react.js는 JSX를 통해 더 쉽게 createElement를 할 수 있음!!
발명가H
2022. 9. 24. 12:26
JSX를 이용해 createElement를 더 쉽게 할 수 있음.
const title = <h3 id = "title" onMouseEnter = {() => console.log("mouse entered")}>Hello, I'm a title</h3>
html과 매우 유사하고 property를 태그처럼 넣어줄 수 있음.
버튼을 만들어보면
const Button = <button style = {{backgroundColor = "tomato", onClick = {() => console.log("I'm clicked")}>Click me</button>
브라우저가 JSX를 이해할 수 있게 하기 위해 babel을 통해 변환을 해줘야 함.