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] TypeError: Cannot read properties of undefined (reading 'startsWith') #3197

Closed
alarv opened this issue Jun 6, 2024 · 7 comments · Fixed by #3240
Closed

[BUG] TypeError: Cannot read properties of undefined (reading 'startsWith') #3197

alarv opened this issue Jun 6, 2024 · 7 comments · Fixed by #3240
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@alarv
Copy link

alarv commented Jun 6, 2024

NextUI Version

2.4.1

Describe the bug

When I create a tabs component with href after following the guide on how to set up routing (with NextUIProvider inside the body wrapping the {children}) I get an error as in the title:

TypeError: Cannot read properties of undefined (reading 'startsWith')
Call Stack
startsWith
../src/shared/lib/router/utils/add-path-prefix.ts
path
../src/client/add-base-path.ts
href
../src/client/components/app-router.tsx
navigate
../src/client/components/app-router.tsx

It seems to happen on nested child elements, cause when I tried it on stackblitz on the app/page.tsx component it seemed to work.

cc @wingkwong created a new issue as requested here: #2934

Your Example Website or App

https://codesandbox.io/p/devbox/zen-moore-knpyrs

Steps to Reproduce the Bug or Issue

  1. Go to https://knpyrs-3000.csb.app/dashboard/tabs
  2. Click on any tab
  3. An error is thrown by nextjs

Expected behavior

As a user I expected the tab to redirect to another tab, but instead an error was thrown.

Screenshots or Videos

No response

Operating System Version

Linux

Browser

Chrome

Copy link

linear bot commented Jun 6, 2024

@wingkwong
Copy link
Member

i copied the same dependencies on my next app but somehow it works fine. Need to dig.

@alarv
Copy link
Author

alarv commented Jun 7, 2024

i copied the same dependencies on my next app but somehow it works fine. Need to dig.

If it helps on the codesandbox, when I switched to npm it stopped working (I also use npm on my project), with pnpm it looked fine

@wingkwong
Copy link
Member

@alarv I also found that this weird behaviour. The path in navigate is undefined when I use npm.

@trival
Copy link

trival commented Jun 13, 2024

I am seeing the exact same think. Using npm, @nextui-org/react@2.4.1, next@14.2.4.

With empty Tab and href attribute, the navigate function is called with undefined as path parameter. Using the Link component instead in the same location works fine.

@trescomasdev
Copy link

I had the same issue, but updating @nextui-org/system, @nextui-org/react and @nextui-org/link to the latest version and import the NextUIProvider from the @nextui-org/system package resolved the issue.
Just to make sure I deleted the node_modules folder after the updates and installed everything again and now the Link are working.

@dwissaaj
Copy link

Hei Any solve for this issue? I also get this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants