Comments (3)
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.
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.
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.
- Locate the Icons file in ~/components
- Find out the lucide icons that the component i.e Select uses by checking the related ~/components/ui/select.ts
- import these icons in the Icon.ts file
- Add a complementary interopIcon(IconName) statement for each icon
- 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)
- [ BUG ] Warning: You are setting the style `{ userSelect: ... }` as a prop. You should nest it in a style object. E.g. `{ style: { userSelect: ... } }` HOT 1
- [ BUG ] Cli is broken HOT 5
- [ BUG ] Cli overwrite HOT 1
- [ BUG ] HOT 1
- [ NativeWind Bug ] The web platform does not work on windows HOT 10
- Add the components preview page HOT 1
- [ FEATURE ] Bottom sheet HOT 1
- Select dropdown does not work inside page which is set to `presentation: "modal"` HOT 4
- Bug: not being able to run the demo project HOT 4
- [ BUG ] Alert crashing on web but working on native HOT 2
- [ BUG ] Nested text with different font size getting cut off HOT 1
- [FEATURE] Shareable UI between Expo and Web
- [ BUG ] Tooltip issues with react-native-reanimated 3.10.0 HOT 1
- [ BUG ] dark modifier on native HOT 2
- [ BUG ] Error during rendering Select component. HOT 3
- [ BUG ] RangeError: Maximum call stack size exceeded when running starter-base templare HOT 1
- [ NativeWind BUG ] darkMode: class not being set, setColorScheme errors HOT 1
- How to open select menu programmatically?
- [ BUG ] Warning: Function components cannot be given refs (Form)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-reusables.