Giter Club home page Giter Club logo

Comments (3)

MikeSchlosser16 avatar MikeSchlosser16 commented on May 24, 2024 2

Thanks @mrzachnugent - I can confirm this resolved it for me using

import { Info, LucideIcon, MoonStar, Plus, Sun, X } from "lucide-react-native";
import { cssInterop } from "nativewind";

function interopIcon(icon: LucideIcon) {
  cssInterop(icon, {
    className: {
      target: "style",
      nativeStyleToProp: {
        color: true,
        opacity: true,
      },
    },
  });
}

interopIcon(Info);
interopIcon(MoonStar);
interopIcon(Sun);
interopIcon(Plus);
interopIcon(X);

export { Info, MoonStar, Plus, Sun, X };

Appreciate your prompt response! I'll be on the look out going forward but think your future state solution makes sense.

from react-native-reusables.

mrzachnugent avatar mrzachnugent commented on May 24, 2024 1

Edit: This issue is caused because a component is trying to import an Icon that you are not yet exporting from the ~/components/Icons file.

To fix this issue:,

  • Find the component that is importing an icon that doesn't exist. Your IDE should have a red squiggly line under the Icon name in its import statement.
  • Go to the ~/components/Icons file
  • Import the missing icon(s) from lucide-react-native
  • For each newly imported icon, call the interopIcon and pass it the icon
  • Export the Icon at the end of the file.

Hey @MikeSchlosser16 Thanks for bringing this up.

To fix this, you have to import, interop, then export the X icon from the ~/components/Icons:

import { Info, LucideIcon, MoonStar, Sun, X } from 'lucide-react-native';
import { cssInterop } from 'nativewind';

function interopIcon(icon: LucideIcon) {
  cssInterop(icon, {
    className: {
      target: 'style',
      nativeStyleToProp: {
        color: true,
        opacity: true,
      },
    },
  });
}

interopIcon(Info);
interopIcon(MoonStar);
interopIcon(Sun);
interopIcon(X);

export { Info, MoonStar, Sun, X };

For Futre Implementation
This issue also occurs in other components. In order to fix this issue, the Cli will add a file for each icon. This way I can easily add icons when components require them. I will also move them to the lib folder.

lib
│
└───Icons
│   │   interopIcon.ts
│   │   Info.tsx
│   │   MoonStar.tsx
│   │   Sun.tsx
│   │   X.tsx

from react-native-reusables.

GeoXhacker avatar GeoXhacker commented on May 24, 2024 1

I was getting that error every time I tried to use Select, DropDownMenu, Dialog. And @mrzachnugent response fixes it.
To break down @mrzachnugent fix for others that might face the same issue before the Bug fix update.

  1. Locate the Icons file in ~/components
  2. Find out the lucide icons that the component i.e Select uses by checking the related ~/components/ui/select.ts
  3. import these icons in the Icon.ts file
  4. Add a complementary interopIcon(IconName) statement for each icon
  5. Add each iconName to the exports

import { Info, LucideIcon, MoonStar, Plus, Sun, X, ...IconNames } from "lucide-react-native";
import { cssInterop } from "nativewind";

function interopIcon(icon: LucideIcon) {
cssInterop(icon, {
className: {
target: "style",
nativeStyleToProp: {
color: true,
opacity: true,
},
},
});
}

interopIcon(Info);
interopIcon(MoonStar);
interopIcon(Sun);
interopIcon(Plus);
interopIcon(X);
interopIcon(IconName);
interopIcon(IconName);
interopIcon(IconName);

export { Info, MoonStar, Plus, Sun, X, ...IconNames };

Thank you for the fix @mrzachnugent
Thank you bringing this up @MikeSchlosser16

from react-native-reusables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.