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

Closed
malezjaa opened this issue May 2, 2024 · 18 comments · Fixed by #2943
Closed

[BUG] - Cannot read properties of undefined (reading 'startsWith') #2934

malezjaa opened this issue May 2, 2024 · 18 comments · Fixed by #2943
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@malezjaa
Copy link

malezjaa commented May 2, 2024

NextUI Version

@nextui-org/link 2.0.29, next.js 14.2.1

Describe the bug

Unhandled Runtime Error
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
React
options
../src/client/components/app-router.tsx
eval
..\..\node_modules\@react-aria\utils\dist\openLink.mjs (29:1)
$ea8dcbcb9ea1b556$var$getSyntheticLink
..\..\node_modules\@react-aria\utils\dist\openLink.mjs (88:1)
Object.open
..\..\node_modules\@react-aria\utils\dist\openLink.mjs (28:1)
onClick
..\..\node_modules\@nextui-org\use-aria-link\dist\index.mjs (42:1)

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

<p className={"text-center"}>
  Need to create an account?
  <Link href={"/register"} className={"ml-1 cursor-pointer"}>
    Sign Up
  </Link>
</p>

When I try to click "Sign Up" I get this error.

This is my providers.tsx:

"use client";

export function Providers({ children, themeProps }: ProvidersProps) {
  const router = useRouter();

  return (
    <AuthProvider>
      <NextUIProvider navigate={router.push}>
        <NextThemesProvider {...themeProps}>{children}</NextThemesProvider>
      </NextUIProvider>
    </AuthProvider>
  );
}

Expected behavior

To redirect

Screenshots or Videos

No response

Operating System Version

Windows

Browser

Chrome

Copy link

linear bot commented May 2, 2024

@malezjaa malezjaa changed the title [BUG] - YOUR_ISSUE_TITLE_HERE_REPLACE_ME [BUG] - Cannot read properties of undefined (reading 'startsWith') May 2, 2024
@hericsantos
Copy link

Same here

@pjatupon
Copy link

pjatupon commented May 3, 2024

me too. i'm change import Link from "@nextui-org/link" to Link from "next/link".

@ryo-manba
Copy link
Member

Could not reproduce. Please provide a link to stackblitz to investigate.

Related issue: #2930

@mozisan
Copy link

mozisan commented May 3, 2024

@armandtht
Copy link

same for me

@wingkwong wingkwong added 🐛 Type: Bug Something isn't working 📦 Scope : Components Related to the components labels May 4, 2024
@wingkwong wingkwong self-assigned this May 4, 2024
@wingkwong
Copy link
Member

wingkwong commented May 6, 2024

The fix will be available in the next release (20th May). At the same time, you can use our canary version as a workaround if necessary.

"@nextui-org/system": "0.0.0-canary-20240504162810"

update NextUIProvider to use @nextui-org/system

import { NextUIProvider } from "@nextui-org/system";

@zhiqingchen
Copy link

Will this fix be released soon? No release on May 20th

@wingkwong
Copy link
Member

@zhiqingchen I'm writing the release note now. Previously we were fully occupied by other internal stuff. Will release soon. Sorry for any inconvenience caused.

@Jihefel
Copy link

Jihefel commented Jun 3, 2024

Is it already fixed in 2.4.1 ?
I still have that error.

@wingkwong
Copy link
Member

@Jihefel yes. please remove node_modules and reinstall. If error still occurs, please share a stackblitz / codesandbox project to us.

@Jihefel
Copy link

Jihefel commented Jun 4, 2024

@Jihefel yes. please remove node_modules and reinstall. If error still occurs, please share a stackblitz / codesandbox project to us.

I followed your instructions but the error still occurs. I think my problem is quite simple. It is not directly linked to the component "Link" (which is actually fixed) but rather to the href prop on a "ListboxItem" component

@alarv
Copy link

alarv commented Jun 4, 2024

This is still happening for me too, the proposed solutions don't work. I tried to reproduce on a stackblitz but to no avail

@elanclarkson
Copy link

elanclarkson commented Jun 5, 2024

This appears to be fixed for links, but not for linked tabs. My use-case is a little different to the documented example so I will see if I can create a repro when I get time. This may not be for a while however, so if anyone else has this issue please feel free to do it instead.

@wingkwong
Copy link
Member

for those who still encounter the issue, please create a new issue with a minimal reproducible example. I need to look into it one by one.

@alarv
Copy link

alarv commented Jun 5, 2024

for those who still encounter the issue, please create a new issue with a minimal reproducible example. I need to look into it one by one.

Hi @wingkwong I was finally able to reproduce the issue, here it is: https://codesandbox.io/p/devbox/zen-moore-knpyrs

If you visit this page: https://knpyrs-3000.csb.app/dashboard/tabs you will be able to reproduce the issue by clicking on any of the tabs.

(EDIT: added a new issue as requested here: #3197)

@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.

@komirellipavan
Copy link

Updating @nextui-org/link to latest version worked for me

@linear linear bot reopened this Aug 31, 2024
@wingkwong wingkwong linked a pull request Aug 31, 2024 that will close this issue
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.