Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Next 13 appDir) TypeError: Cannot read properties of null (reading 'useContext') #4048

Closed
blakeley opened this issue Jan 10, 2023 · 3 comments
Assignees
Labels
kind/bug Something isn't working status/done
Projects

Comments

@blakeley
Copy link

blakeley commented Jan 10, 2023

What is the problem?

I updated to I updated next to 13 & blitz to beta 21, and this resulted in an error at first render:

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

I've changed all instances of useRouter to import from 'next/navigation', as instructed:

import { useRouter } from "next/navigation"

And all files in this render tree have 'use client' at the top.

What else am I missing?

Paste all your error logs here:

event - compiled client and server successfully in 4.8s (1317 modules)
wait  - compiling /404 (client and server)...
event - compiled client and server successfully in 305 ms (1307 modules)
Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
TypeError: Cannot read properties of null (reading 'useContext')
    at Object.useContext
    at Object.useRouter
    at BlitzProvider
    at renderWithHooks 
    at renderIndeterminateComponent
    at renderElement 
    at renderNodeDestructiveImpl
    at renderNodeDestructive 
    at renderIndeterminateComponent 
    at renderElement

Paste all relevant code snippets here:

n/a

What are detailed steps to reproduce this?

Run blitz -v and paste the output here:

Blitz version: 2.0.0-beta.20 (global)
Blitz version: 2.0.0-beta.21 (local)
macOS Ventura | darwin-arm64 | Node: v18.12.1


 Package manager: npm

  System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 269.31 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  npmPackages:
    @blitzjs/auth: v2.0.0-beta.21 => 2.0.0-beta.21 
    @blitzjs/next: v2.0.0-beta.21 => 2.0.0-beta.21 
    @blitzjs/rpc: v2.0.0-beta.21 => 2.0.0-beta.21 
    @prisma/client: 4.0.0 => 4.0.0 
    blitz: v2.0.0-beta.21 => 2.0.0-beta.21 
    next: 13.1.1 => 13.1.1 
    prisma: 4.0.0 => 4.0.0 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: 4.8.2 => 4.8.2 ```


### Please include below any other applicable logs and screenshots that show your problem:

_No response_
@MadcowD
Copy link

MadcowD commented May 15, 2023

Having same issue

@MadcowD
Copy link

MadcowD commented May 15, 2023

@siddhsuresh what was the fix?

@MadcowD
Copy link

MadcowD commented May 16, 2023

For me it was that blitx is not compatible with next 13.4.2, next 13.3.0 is fine though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/done
Projects
Development

No branches or pull requests

4 participants