nativewind icon indicating copy to clipboard operation
nativewind copied to clipboard

[v4]: Third party component does not apply styles, version 4.0.24 or later

Open buildtheui opened this issue 2 years ago • 2 comments

Description:

Following the update to Nativewind version 4.0.24 or later, the previously functional capability to apply styles using the className property on lucide-react-native components no longer works, where className was used extensively for styling purposes on each icon. The current workaround involves using cssInterop for each icon, which involves manual changes across the project.

Steps to Reproduce:

  1. Ensure the latest version of lucide-react-native is installed.
  2. Upgrade Nativewind to version 4.0.24 or above.
  3. Attempt to style a lucide-react-native icon using the className property, as demonstrated below:
import { CalendarCheck } from "lucide-react-native";

// Example usage demonstrating the issue
<CalendarCheck size={14} className="text-red-500 rotate-45" />

Observed Behavior:

Styles specified via the className property are not applied to the icons. The suggested workaround is to employ cssInterop as follows, which poses significant refactoring challenges:

import { CalendarCheck } from "lucide-react-native";

cssInterop(CalendarCheck, { className: "style" });

Expected Behavior:

The className property should work on components with the style prop

Environment Details:

React Native version: 0.73.4 Nativewind version: 4.0.24 and later lucide-react-native version: ^0.315.0 Operating System: iOS simulator Expo: 50.0.8

buildtheui avatar Feb 29 '24 22:02 buildtheui

Having the same issue with https://github.com/duongdev/phosphor-react-native

My workaround looks like this but I won't benefit from tree-shaking:

import * as PhsophorIcons from 'phosphor-react-native'

Object.values(PhsophorIcons).forEach((pi) => {
    if (isReactComponent(pi)) {
      cssInterop(pi, {className: 'style'} as any)
    }
  })

binchik avatar Mar 18 '24 09:03 binchik

@binchik Pretty good solution.. As metro doesn't tree shake this shouldn't impact anything.

feledori avatar Mar 18 '24 11:03 feledori

We are closing all pre-v4.1 issues now that v4.1 is released. If the problem is still happening with the latest v4.1, please open a new issue and reference this one in the description.

danstepanov avatar Sep 02 '24 23:09 danstepanov