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

Bug with NextJS 13.4.1 & custom server #2611

Closed
sgarnotel opened this issue May 10, 2023 · 3 comments
Closed

Bug with NextJS 13.4.1 & custom server #2611

sgarnotel opened this issue May 10, 2023 · 3 comments

Comments

@sgarnotel
Copy link

sgarnotel commented May 10, 2023

Bug report

Description / Observed Behavior

This error throw when using useSWR with NextJS 13.4.1 and a custom server

- error TypeError: Cannot read properties of null (reading 'useContext')
    at useContext (/home/simon/Documents/Git/Airthium/next-swr-issue/node_modules/react/cjs/react.development.js:1618:21)
    at useSWRConfig (file:///home/simon/Documents/Git/Airthium/next-swr-issue/node_modules/swr/_internal/dist/index.mjs:580:40)
    at useSWRArgs (file:///home/simon/Documents/Git/Airthium/next-swr-issue/node_modules/swr/_internal/dist/index.mjs:614:32)
    at useApi (webpack-internal:///./src/api/index.tsx:41:87)
    at Home (webpack-internal:///./src/pages/index.tsx:26:67)

Without custom server, it works well

Expected Behavior

No error

Repro Steps / Code Example

Repro

Run without custom server:

  • yarn && yarn dev, Works well

Run with custom server:

  • yarn && yarn customserver, Bug

Additional Context

SWR version. 2.1.5

If you uncomment transpilePackages: ["swr"] in next.config.js, all works with the custom server. I do not understand why.

No problem with NextJS 13.3.4

@promer94
Copy link
Collaborator

It's more like a bundle issue rather than a problem of SWR. I think you could get assistances from communities of Nextjs or SWC

@promer94 promer94 closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
@vncsalencar
Copy link

@sgarnotel you ever found a fix for this?

@sgarnotel
Copy link
Author

I do not remember what I have done to fix that, but this is related to this repo, you can have a look on configuration files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants