Skip to content
Source
Sign inSign up
TanStack/query

TypeError: Cannot read properties of null (reading 'useEffect') #5419

Send to my agent
Closeddexter4life(GitHub profile, opens in a new tab) opened this issue 10 comments

Describe the bug

Hello everyone, I need your help.

During project development everything work so well, and no error. But compiling into production I started having this error when I try to run the nextjs application using this

node ./index.js

below is the error messages

  • error TypeError: Cannot read properties of null (reading 'useEffect') at Module.useEffect (C:\ProjectDevelopment\project\node_modules\react\cjs\react.development.js:1634:21) at QueryClientProvider (file:///C:/ProjectDevelopment/project/node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs:46:9)

Your minimal, reproducible example

i don't have a link

Steps to reproduce

  1. I install tanstack@react-query
  2. Installed react/react-dom for a UI component depending on it on nextjs
  3. Using a nextjs custom server
  4. compile using tsc
  5. run node ./index.js

Expected behavior

Everything compile properly at first, but then when I try to open the package then I get this

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

So what I expect to happen is for the react-query to work, either for the page to load successfully

How often does this bug happen?

Every time

Screenshots or Videos

image

Platform

  • OS: Windows 11
  • Browser: Chrome
  • Version 113.0.5672.93

Tanstack Query adapter

react-query

TanStack Query version

4.29.7

TypeScript version

4.7.4

Additional context

I want to know what step I need to take to fix this as soon as possible.

  1. I don't think you spent any time searching the closed issues, because there is a closed issue with the exact same title:

  2. TkDodo closed this

  3. TkDodo added labelsduplicate

  4. I did but can't find any solution. Please help me 🙏

  5. it's a nextJs issue. Please ask for advice on their linked issue, or downgrade to 13.3

  6. Found a solution, I will try it. Thanks

  7. Found a solution, I will try it. Thanks

    Hey ! @dexter4life I experimenting the same in my nx monorepo, so as i can see, you find a solution, can you shared it with me :( ???

    Thanks for your answer and have a good day !

  8. @wilfriedago you will need to add this

    experimental: { appDir: false },

    to your nextjs config file.

  9. @dexter4life i try it, but it not working, i'm not using appDir, and i'm inside a nx monorepo

  10. Up. Does anyone still have this issue?

  11. yes on version 13.4.1, but it was resolved when I update to version 13.5.5

  12. hmm.. I'am not in nextjs project but react

Sign in to join this conversation.