본문 바로가기 메뉴 바로가기

박레고의 이야기

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

박레고의 이야기

검색하기 폼
  • 분류 전체보기 (10)
    • CSS (2)
    • JavaScript (2)
    • TypeScript (0)
    • React (2)
    • React Native (1)
    • Java (1)
    • Environment (2)
    • AI (0)
  • 방명록

useState (1)
useState와 useReducer 둘 중 무엇을 사용해야 할까?

1.  useState리액트에서 상태관리라고 하면, 가장 먼저 떠오르는 hooks 중 하나로 useState를 뽑을 수 있다.컴포넌트에서 state를 동적으로 관리하기 위해서 자주 사용되는 함수이다.// 사용방법const [state, setState] = useState(initialState);// 예시const [name, setName] = useState("");// 초기값console.log(name); // ''// name state 재할당setName("박레고");// 랜더링 이후console.log(name); // 박레고setName함수를 통해 name의 값을 변경해줄 수 있다. setName은 상태 값을 갱신해주는 Setter 함수라고 한다. 2.  useReducer그렇다면, us..

React 2023. 3. 5. 19:11
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • jdk
  • this
  • Pressable
  • useMemo
  • button
  • React Native
  • zoom
  • css
  • bind
  • useRef
  • javascript
  • 고정
  • withcredentials
  • background-attachment
  • jenv
  • touchableopacity
  • 스크롤
  • CORS
  • useReducer
  • yml
  • React
  • yaml
  • window.location
  • custom hooks
  • React Hooks
  • 상태관리
  • 리액트
  • useState
more
«   2025/07   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함
반응형

Blog is powered by Tistory / Designed by Tistory

티스토리툴바