[TIL] Reason Why set the ContextProvider(ex.Redux StoreProvider) inside the body tag, not the outside of root layout.
Oct 16, 2024 | Oct 16, 2024
| Ryoon.With.Wisdomtrees
Root Layout은 기본적으로 ServerComponent로서의 역할만을 하도록 유지하는것이 좋다.
그러므로
위와 같이 설정해두는 것. 여기서 DashboardWrapper 전체 코드는 아래와 같은데,
- React
useEffect
이 구성 요소는 클라이언트 구성 요소여야 하며'use client'
맨 위에 지시문이 필요하다.
- use client를 명시해둔 이 컴포넌트가 ServerComponent 전체를 감싸면 안됨.
- 왜냐면, “When a component module contains a
'use client'
directive, any usage of that component is guaranteed to be a Client Component. However, a component can still be evaluated on the client even if it does not have a'use client'
directive.” - 출처:https://react.dev/reference/rsc/use-client
뒤로