You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SWRConfig is used for top class components (e.g. layout), but the component SWRConfig is not defined as the Client Components.
Therefore, developer have to write "use client", which makes all components in the layout as Client Components.
Description / Observed Behavior
Server Error
TypeError: react.createContext is not a function
Expected Behavior
Therefore, the developer must write "use client", which makes all components in the layout client components.
Additional Context
swr: 1.3.0
next: 13.0.2
The text was updated successfully, but these errors were encountered:
The current workaround would be manually wrapping <SWRConfig /> in your client components:
// my-provider.client.tsx'use client';exportconstMyProvider=({ children }: React.PropWithChildren<unknown>)=>{return<SWRConfig>{children}</SWRConfig>};// layout.tsxexportdefaultfunctionLayout({ children }: React.PropWithChildren<unknown>){return<MyProvider>{children}</MyProvider>}
And IMHO <SWRConfig /> should also include import 'client-only'.
Bug report
SWRConfig is used for top class components (e.g. layout), but the component
SWRConfig
is not defined as the Client Components.Therefore, developer have to write
"use client"
, which makes all components in the layout as Client Components.Description / Observed Behavior
Expected Behavior
Therefore, the developer must write
"use client"
, which makes all components in the layout client components.Additional Context
swr: 1.3.0
next: 13.0.2
The text was updated successfully, but these errors were encountered: