lucide icon indicating copy to clipboard operation
lucide copied to clipboard

Hide error message "Name in Lucide DynamicIcon not found" for DynamicIcon when a valid fallback component is present

Open maurer2 opened this issue 1 month ago • 0 comments

Package

  • [ ] lucide
  • [ ] lucide-angular
  • [ ] lucide-flutter
  • [ ] lucide-preact
  • [x] lucide-react
  • [ ] lucide-react-native
  • [ ] lucide-solid
  • [ ] lucide-svelte
  • [ ] lucide-vue
  • [ ] lucide-vue-next
  • [ ] Figma plugin
  • [ ] all JS packages
  • [ ] site

Description

Hello, I've been playing around with the new DynamicIcon component, described here as a replacement for "lucide-react/dynamicIconImports". I noticed that when using an incorrect name prop, the fallback component is rendered instead, but there still the following error message in dev mode: "Name in Lucide DynamicIcon not found". I don't seem to be able to handle that error via an error boundary. Example:

<DynamicIcon name="invalidName" fallback={() => <p>Some fallback content like a default icon</p>} />

Use cases

Hiding the error message or downgrading it to a warning, when there is a valid fallback component, would make working with dynamic icon names via props more pleasant, as showing a fallback component for an icon wouldn't automatically trigger an error.

Checklist

  • [x] I have searched the existing issues to make sure this bug has not already been reported.

maurer2 avatar Jan 22 '25 00:01 maurer2