Skip to content

Commit 610925c

Browse files
committed
feat: add NativeWind support and update documentation
1 parent 670e239 commit 610925c

6 files changed

Lines changed: 73 additions & 3 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ The skill will:
3737
4. Let you select which components to migrate
3838
5. Apply the changes, preserving all non-animation logic
3939

40+
### NativeWind Support
41+
42+
If you're using [NativeWind](https://www.nativewind.dev/) (v4+), add this import once in your app's entry point (e.g., `_layout.tsx` or `App.tsx`):
43+
44+
```tsx
45+
import 'react-native-ease/nativewind';
46+
```
47+
48+
This registers `EaseView` with NativeWind's `cssInterop` so `className` is properly converted to styles:
49+
50+
```tsx
51+
<EaseView
52+
className="flex-1 bg-white rounded-2xl p-4"
53+
animate={{ opacity: visible ? 1 : 0 }}
54+
transition={{ type: 'timing', duration: 300 }}
55+
>
56+
{children}
57+
</EaseView>
58+
```
59+
60+
> **Tip:** If you use the [migration skill](#migration-skill), it detects NativeWind automatically and adds this import for you.
61+
4062
### Example
4163

4264
```tsx

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"types": "./lib/typescript/src/index.d.ts",
1111
"default": "./lib/module/index.js"
1212
},
13+
"./nativewind": {
14+
"source": "./src/nativewind.ts",
15+
"types": "./lib/typescript/src/nativewind.d.ts",
16+
"default": "./lib/module/nativewind.js"
17+
},
1318
"./package.json": "./package.json"
1419
},
1520
"files": [
@@ -98,7 +103,13 @@
98103
},
99104
"peerDependencies": {
100105
"react": "*",
101-
"react-native": "*"
106+
"react-native": "*",
107+
"nativewind": ">=4"
108+
},
109+
"peerDependenciesMeta": {
110+
"nativewind": {
111+
"optional": true
112+
}
102113
},
103114
"workspaces": [
104115
"example"

skills/react-native-ease-refactor/SKILL.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ Follow these 6 phases exactly. Do not skip phases or reorder them.
1616

1717
Scan the user's project for animation code:
1818

19-
1. Use Grep to find all files importing from `react-native-reanimated`:
19+
1. Use Grep to detect if the project uses NativeWind:
20+
21+
- Pattern: `from ['"]nativewind['"]` in `**/*.{ts,tsx,js,jsx}`
22+
- Also check `package.json` for `"nativewind"` in dependencies
23+
- If NativeWind is detected, set a flag `usesNativeWind = true` for use in Phase 5
24+
25+
2. Use Grep to find all files importing from `react-native-reanimated`:
2026

2127
- Pattern: `from ['"]react-native-reanimated['"]`
2228
- Search in `**/*.{ts,tsx,js,jsx}`
@@ -251,6 +257,8 @@ For each confirmed component, apply the migration:
251257
import { EaseView } from 'react-native-ease';
252258
```
253259

260+
1b. **If `usesNativeWind` is true**, check if `import 'react-native-ease/nativewind'` already exists in the project (search all files). If not, add it to the app's root entry point (e.g., `_layout.tsx`, `App.tsx`, or `index.tsx` — whichever is the earliest entry). This only needs to be done once across all migrations, not per component.
261+
254262
2. **Replace the animated view:**
255263

256264
- `Animated.View``EaseView`

src/__tests__/nativewind.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const mockCssInterop = jest.fn();
2+
3+
jest.mock(
4+
'nativewind',
5+
() => ({
6+
cssInterop: mockCssInterop,
7+
}),
8+
{ virtual: true },
9+
);
10+
11+
// Import after mock is set up
12+
import { EaseView } from '../EaseView';
13+
14+
describe('nativewind entry point', () => {
15+
it('calls cssInterop with EaseView and className → style mapping', () => {
16+
require('../nativewind');
17+
18+
expect(mockCssInterop).toHaveBeenCalledTimes(1);
19+
expect(mockCssInterop).toHaveBeenCalledWith(EaseView, {
20+
className: 'style',
21+
});
22+
});
23+
});

src/nativewind.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @ts-ignore – nativewind is an optional peer dependency
2+
import { cssInterop } from 'nativewind';
3+
import { EaseView } from './EaseView';
4+
5+
cssInterop(EaseView, { className: 'style' });

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"rootDir": ".",
44
"paths": {
5-
"react-native-ease": ["./src/index"]
5+
"react-native-ease": ["./src/index"],
6+
"react-native-ease/nativewind": ["./src/nativewind"]
67
},
78
"allowUnreachableCode": false,
89
"allowUnusedLabels": false,

0 commit comments

Comments
 (0)