Youtube를 보다가 'Top 6 React Hook Mistakes Beginners Make' 라는 관심을 가질 만한 영상을 찾았다. 이 영상을 보고 나는 얼마나 실수를 하고 있으며, 실수를 하고 있다면 고치기 위하여 해당 내용을 정리하면서 포스팅하기로 하였다. 리액트 훅은 기본적으로 알고 있다고 생각하고 진행하겠다. 1. Using state when you don't need itimport React, { useState } from "react";function Mistakes() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); function onSubmit(e) { e...
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..
- Total
- Today
- Yesterday
- background-attachment
- withcredentials
- useReducer
- this
- 스크롤
- CORS
- 상태관리
- useRef
- bind
- css
- zoom
- jdk
- javascript
- 고정
- jenv
- useState
- useMemo
- touchableopacity
- Pressable
- yml
- custom hooks
- yaml
- React Native
- React Hooks
- button
- React
- window.location
- 리액트
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |