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

Space in the beginning of classname crashes Nextjs app #456

Closed
callmearta opened this issue Aug 12, 2024 · 3 comments · Fixed by #457
Closed

Space in the beginning of classname crashes Nextjs app #456

callmearta opened this issue Aug 12, 2024 · 3 comments · Fixed by #457
Labels
bug Something isn't working context-v2 Related to tailwind-merge v2

Comments

@callmearta
Copy link

Describe the bug

cn(" text-white") causes nextjs page crash in browser giving out of memory error. cn("text-white") fixes the issue. that space took me 6 hours to find out about. Worked fine before new release. cn is also a function that uses clsx and tailwind-merge to combine classnames.

To Reproduce

  1. create a nextjs app
  2. create the cn function as below:
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
 
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}
  1. use cn(" text-white") classname as an example.
  2. the page crashes in browser while it is on a not much powerful server. I still don't understand why it is related to the server cpu causing client browser to crash.

Expected behavior

No crash in browser.

Environment

nextjs v14.2.5
clsx v2.0.0

@github-actions github-actions bot added the context-v2 Related to tailwind-merge v2 label Aug 12, 2024
@dcastil dcastil added the bug Something isn't working label Aug 12, 2024
@dcastil
Copy link
Owner

dcastil commented Aug 12, 2024

Hey @callmearta! 👋

I can reproduce it, fix will come soon. Sorry for the troubles!


Caused by #450

@callmearta
Copy link
Author

Thanks for the useful lib and your time.

Copy link

This was addressed in release v2.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working context-v2 Related to tailwind-merge v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants