Next.js Discord

Discord Forum

ReactServerComponentsError in pages directory

Answered
Flammulated Owl posted this in #help-forum
Open in Discord
Flammulated OwlOP
I'm having this error while compiling my _app.tsx file. I assumed that you didn't need to specify "use client" in every page of the pages directory. What's going on?

[0] ReactServerComponentsError:
[0]
[0] You're importing a component that needs createContext. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
[0] Learn more: https://nextjs.org/docs/getting-started/react-essentials
[0]
[0]    ,-[C:\...\next\src\api\hooks\use-me.tsx:1:1]
[0]  1 | import { trpc } from "@/lib/trpc/client";
[0]  2 | import { createContext, useContext } from "react";
[0]    :          ^^^^^^^^^^^^^
[0]  3 |
[0]  4 | export const OverrideControlloContext = createContext<string | null>(null);
[0]    `----
[0]
[0] Maybe one of these should be marked as a client entry with "use client":
[0]   ./src\api\hooks\use-me.tsx
[0]   ./src\pages\_app.page.tsx
Answered by Flammulated Owl
nevermind, I messed up the webpack config
View full answer

1 Reply

Flammulated OwlOP
nevermind, I messed up the webpack config
Answer