Next.js Discord

Discord Forum

TypeError: Cannot read properties of null (reading 'useContext')

Unanswered
Crème D’Argent posted this in #help-forum
Open in Discord
Crème D’ArgentOP
Sometimes I encounter this random bug where I cannot read properties of null (reading 'useContext'), even though my code doesn't even contain a useContext. In the console, I receive additional information related to usePathname. This issue only occurs on localhost and is very random.

To resolve it, I simply restart the development server, but it's becoming increasingly annoying.

3 Replies

Are you using pages router somewhere?
Also make sure to do null checks when using usePathname although i doubt the issue is with that and maybe something internal.

If you arent using the pages router then try downgrading and checking if the issue persists. Also consider opening a issue on GitHub
Crème D’ArgentOP
I'm only using app router