-
[React] 새로운 리액트 문서에서 제시하는 9가지 권장 사항프로그래밍/React 2023. 12. 6. 11:26
출처: https://blog.testdouble.com/posts/2023-10-16-react-docs-recommendations/
개요
- 9가지 권장사항
권장사항
- 반복문에 key에 index 넣지마라
- 컴포넌트 정의할 때 중첩으로 사용하지마라
- state 남발하지마라 꼭 필요한 상황에서 최소한으로 사용해라
- useMemo, useCallback, React.memo 남발하지마라
- "use" 접두사 사용하는 것을 남발하지마라
- useEffect 를 올바르게 사용하자 프로퍼티 변경에 따라 상태를 조정해야한다면 사용하지마라
- 데이터 페칭은 useEffect보다 라이브러리가 낫다
- 이벤트 발생에 대한 응답으로 어떠한 액션을 취한다면 useEffect를 사용하지말고 핸들러에 코드를 작성해라
- useEffect 종속성을 생각하면서 종속성 배열에 설정을 하고 원치 않는 리렌더링이 발생한다면 종속성을 제거해라
'프로그래밍 > React' 카테고리의 다른 글
[React] useState의 동작원리 (0) 2023.12.16 [React] react-hook-form (Basic) (0) 2023.12.08 [React] Suspense (2) 2023.11.22 [Hooks] useEffect (1) 2023.11.22 [Article] React 렌더링 동작에 대한 (거의) 완벽한 가이드(1편) (0) 2023.11.21