Bug: uniwind transformer causes runtime crash with @react-navigation/elements
Environment
- Expo SDK 54
- React Native 0.81.5 (New Architecture enabled)
- uniwind (latest)
- @react-navigation/native-stack ^7.8.6
- @react-navigation/elements 2.9.3
Error
TypeError: Cannot convert undefined value to object
Runtime crash when importing @react-navigation/elements (directly or via @react-navigation/native-stack).
Root Cause
The CSS template literal in @react-navigation/elements/lib/module/PlatformPressable.js conflicts with uniwind's Metro transformer:
const css = String.raw;
const CSS_TEXT = css`
.__react-navigation_elements_Pressable_hover {
position: absolute;
...
}
`;
Reproduction
- Create Expo project with React Navigation 7 and uniwind
- Enable package exports (required for React Navigation 7):
config.resolver.unstable_enablePackageExports = true
- Import any navigator from
@react-navigation/native-stack
- App crashes at runtime
Tested Configurations
| Configuration |
Result |
| No uniwind + package exports |
✅ Works |
| uniwind + package exports |
❌ Crashes |
| uniwind + no package exports |
❌ Crashes |
| Custom transformer skipping @react-navigation |
❌ Crashes |
| Empty CSS file with uniwind |
❌ Crashes |
Workaround / Resolution
Option 1: Yarn Patch (Recommended)
-
Start the patch:
yarn patch @react-navigation/elements
-
Edit lib/module/PlatformPressable.js in the temp folder - replace lines 97-144 with:
// PATCHED: Removed CSS template literal that conflicts with uniwind
const HoverEffect = ({ color, hoverOpacity = 0.08, activeOpacity = 0.16 }) => {
if (Platform.OS !== 'web' || color == null) {
return null;
}
return null;
};
-
Commit the patch:
yarn patch-commit -s <temp-folder-path>
-
Run yarn install to apply
This patch survives yarn install, npx expo prebuild, and reinstalls.
Option 2: Fix in uniwind
uniwind should handle/skip CSS template literals in node_modules packages to avoid conflicts with third-party libraries.
Expected Behavior
uniwind should handle or skip files containing CSS template literals from third-party packages without causing runtime crashes.
This issue was created with the assistance of Claude Code.
Bug: uniwind transformer causes runtime crash with
@react-navigation/elementsEnvironment
Error
Runtime crash when importing
@react-navigation/elements(directly or via@react-navigation/native-stack).Root Cause
The CSS template literal in
@react-navigation/elements/lib/module/PlatformPressable.jsconflicts with uniwind's Metro transformer:Reproduction
@react-navigation/native-stackTested Configurations
Workaround / Resolution
Option 1: Yarn Patch (Recommended)
Start the patch:
Edit
lib/module/PlatformPressable.jsin the temp folder - replace lines 97-144 with:Commit the patch:
Run
yarn installto applyThis patch survives
yarn install,npx expo prebuild, and reinstalls.Option 2: Fix in uniwind
uniwind should handle/skip CSS template literals in node_modules packages to avoid conflicts with third-party libraries.
Expected Behavior
uniwind should handle or skip files containing CSS template literals from third-party packages without causing runtime crashes.
This issue was created with the assistance of Claude Code.