Space in the beginning of classname crashes Nextjs app #456
Closed
Description
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
- create a nextjs app
- 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))
}
- use cn(" text-white") classname as an example.
- 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