Context in App dir
I just wanted to understand , if I have global context providers that I need to use in all components, would it be possible to still use server components using app dir in Nextjs if I wrap the children in context
Example from next documentation:
import { ThemeProvider } from 'acme-theme';
export default function RootLayout({ children }) {
return (
<html>
<body>
{/* Error:
<ThemeProvider>{children}</ThemeProvider>
</body>
</html>
);
}
Example from next documentation:
import { ThemeProvider } from 'acme-theme';
export default function RootLayout({ children }) {
return (
<html>
<body>
{/* Error:
createContext can't be used in Server Components */}<ThemeProvider>{children}</ThemeProvider>
</body>
</html>
);
}