![[ react ] documentation useState ( 18.2.0 )](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FczzBQ2%2FbtsJyfS8Yvy%2Fy7mgRqxa0KnN5cLV34MMlK%2Fimg.png)
Frontend/react2024. 9. 10. 19:43[ react ] documentation useState ( 18.2.0 )
useState(initialState) 컴포넌트의 최상위 레벨에서 useState를 호출하여 state 변수를 선언하세요. import { useState } from 'react';function MyComponent() { const [age, setAge] = useState(28); const [name, setName] = useState('Taylor'); const [todos, setTodos] = useState(() => createTodos()); // ...Parameters initialState : 초기 state 설정할 값입니다. 값은 모든 데이터 타입이 허용되지만 , 함수에 대해서는 특별한 동작이 있습니다. 이 인자는 초기 렌더링 이후에는 무시됩니다. 함수를 init..