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을 통해 변환을 해줘야 함.
'개발 > react' 카테고리의 다른 글
react.useState()는 데이터를 업데이트하는데 이용함!! (1) | 2022.09.24 |
---|---|
react.js는 바뀌는 부분만 업데이트한다는 점이 최고의 장점!! (0) | 2022.09.24 |
react component를 다른 component에 넣으려면 함수로 만들어줌!! (0) | 2022.09.24 |
react.js는 property에 event를 등록할 수 있음!! (0) | 2022.09.24 |
react.js는 javascript에서 시작해 html에서 끝남! (0) | 2022.09.24 |