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

ERROR: "Class extends value undefined is not a constructor or null" after running Next.js 13 with app dir #2753

Open
naseef0 opened this issue May 18, 2023 · 9 comments

Comments

@naseef0
Copy link

naseef0 commented May 18, 2023

  • components: NavLink
  • reactstrap version #9.1.10
  • react version #18.2.0
  • bootstrap version #x.x.x
  • nextjs version #13.4.2

What is happening?

After installing reactstrap in to my next 13 app Showing error "Class extends value undefined is not a constructor or null"
I dint even import any components from reactstrap. still showing this error

What should be happening?

Steps to reproduce issue

  1. create next js 13 app with app dir
  2. install latest reactstrap
  3. npm run dev

Error message in console

  • error node_modules\reactstrap\lib\NavLink.js (35:37) @ Component
  • error Class extends value undefined is not a constructor or null
- error node_modules\reactstrap\lib\NavLink.js (35:37) @ Component
- error Class extends value undefined is not a constructor or null

This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component

This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component
    at __webpack_require__ (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\webpack-runtime.js:33:42)
    at __webpack_require__ (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\webpack-runtime.js:33:42)
    at eval (./src/components/core/Container.jsx:5:68)
    at Object.(sc_server)/./src/components/core/Container.jsx (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\app\[lang]\page.js:7067:1)  
    at __webpack_require__ (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\webpack-runtime.js:33:42)
    at eval (./src/app/[lang]/page.js:8:73)
    at Object.(sc_server)/./src/app/[lang]/page.js (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\app\[lang]\page.js:7056:1)
    at Function.__webpack_require__ (C:\Users\Naseef\OneDrive\Desktop\playground\poc\saleor\storefront\.next\server\webpack-runtime.js:33:42)
null

Code

@hsk-kr
Copy link

hsk-kr commented May 19, 2023

You should use

"use client";

on the top of the file you used a component NavLink.

@naseef0
Copy link
Author

naseef0 commented May 20, 2023

You should use

"use client";

on the top of the file you used a component NavLink.

@hsk-kr I didn't use NavLink but instead installed reactstrap and re-ran the Next.js app. However, I encountered the error mentioned above during this process.

@hsk-kr
Copy link

hsk-kr commented May 20, 2023

@naseef0 I installed reactstrap and ru-run the Next.js app. It seems working out well.

The following is my package.json.

{
  "name": "reactstrap-test-01",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@types/node": "20.2.1",
    "@types/react": "18.2.6",
    "@types/react-dom": "18.2.4",
    "bootstrap": "^5.2.3",
    "eslint": "8.40.0",
    "eslint-config-next": "13.4.3",
    "next": "13.4.3",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "reactstrap": "^9.1.10",
    "typescript": "5.0.4"
  }
}

@hetu06
Copy link

hetu06 commented May 22, 2023

I added a "user client" page, however it didn't work because of an issue that showed me in the console how to fix it.

https://ibb.co/VYxHsYV

You may view the screenshot I uploaded here.

Let me know if there is a solution, please.

Many thanks

@LowScarlet
Copy link

same here, idk why

@naseef0
Copy link
Author

naseef0 commented Jun 3, 2023

Anu updates?

@acocheo
Copy link

acocheo commented Jul 19, 2023

same here

@dedikisme
Copy link

dedikisme commented Oct 13, 2023

add "use client" on components that call reactstrap element and the children will automatically render as client.
for example you call reactstrap components from layout.tsx then you should put "use client" on layout.tsx
I solved with this

https://nextjs.org/docs/app/building-your-application/rendering/client-components

@jorgev259
Copy link

Any updates on this

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

7 participants