React
-
JSX, useStateReact 2022. 12. 19. 21:22
JSX 대표적인 JSX 문법 3개 class class를 추가하고 싶을 땐 "className" 인라인 style 적용 인라인으로 style을 적용하고 싶을 땐 중괄호 두개 안에 입력 변수를 넣을 땐 중괄호 let 변수 = 'Im 변수' { 변수 } useState - 자주 변경할 것 같은 변수는 useState로 관리하자. function App(){ let [변수이름, 변수 내용을 변경할 때 쓸 변수이름] = useState('변수에 넣을 내용'); return ( {변수이름} ) } 이렇게 변수 형식으로 함수 안에 넣어주면 된다. useState를 써야하는 이유 - state를 쓰던 html은 state 가 변경되면 자동 재랜더링이 되고있다. - 한개의 useState에 여러개의 값을 넣기. fun..