lucide-icons / lucide

Beautiful & consistent icon toolkit made by the community. Open-source project and a fork of Feather Icons.
https://lucide.dev
ISC License
10.47k stars 474 forks source link

NextJs 14 className hydration bug. #2498

Open nandy1990 opened 1 day ago

nandy1990 commented 1 day ago

Package

Version

0.446.0

Can you reproduce this in the latest version?

Browser

Operating system

Description

When using "use client" className differs by trailing whitespace between server and client. Inside off createLucideIcon.js className gets joined together by following line 23:

className: ["lucide", lucide-${toKebabCase(iconName)}, className].join(" ")

so if className is empty you end up having a trailing space.

Console output in browser:

Warning: Prop className did not match. Server: "lucide lucide-euro " Client: "lucide lucide-euro" at svg...

Steps to reproduce

Any file with "use client" and rendering any icon without className specified leads to this warning/error

Checklist

bsimpson888 commented 1 day ago

Hello together, I face exactly the same bug. By trimming the resulting className string, the error is gone. Could someone please add the .trim() after the .join(" ") to this line.