Next.js Discord

Discord Forum

Dynamic page Cannot read properties of null (reading 'useContext')

Unanswered
Philippine Crocodile posted this in #help-forum
Open in Discord
Philippine CrocodileOP
I am using app router and in /app I created /genres/[slug]/page.tsx
In page.tsx i have
export default function Page({ params }: { params: { slug: string } }) {
  return <div>My Post: {params.slug}</div>;
}

when running next dev however the page doesnt load and returns an error
TypeError: Cannot read properties of null (reading 'useContext')


Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 22.1.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.1.0
Relevant Packages:
  next: 14.2.3 // There is a newer version (14.2.4) available, upgrade recommended! 
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5

2 Replies

Philippine CrocodileOP
I set 'use client'; at the top and the issue went away
not sure why it is explicitly needed to be set
Lakeland Terrier
As I understand it, everything defaults to use server. So all of the "use client"s must be declared.