728x90
React Rules of Hooks
Only call React Hooks in React Functions
- React Component Functions
- Custom Hooks
Only call React Hoos at the Top Level
- Don't call them in nested functions
- Don't call them in any block statements
+ extra, unoffical Rule for useEffect(): ALWAYS add everything you refer to inside of useEffect() as a dependency
useEffect(() => {
setFormIsValid(email && password)
}, [email]); // (x)
useEffect(() => {
setFormIsValid(email && password)
}, [email, password]); // (o)
728x90
'Study Note > React' 카테고리의 다른 글
React #Redux (0) | 2022.09.24 |
---|---|
React #Building Custom Hooks (0) | 2022.09.24 |
React #Understanding useReducer() (0) | 2022.09.24 |
React #mongoose #페이지네이션 구현 (0) | 2021.03.17 |
React #joi 로 유효성 검증하기 (0) | 2021.03.17 |
댓글