Skip to content

react-native-css/components does not re-export AssetRegistry (breaks expo-asset on RN 0.88) #570

Open

Description

@dvynohradovv

Description

Since NativeWind v5 / react-native-css redirects every non-internal import ... from "react-native" to react-native-css/components, anything that reads a React Native export missing from components/index.cjs gets undefined.

AssetRegistry became part of the public react-native API in RN 0.88 (index.js has get AssetRegistry()), but it is not listed in src/components/index.cts (and the shipped dist/*/components/index.cjs).

expo-asset does import { AssetRegistry } from 'react-native', so it receives undefined.

Environment

  • react-native-css 3.1.0-rc.0 (nativewind 5.0.0-rc.0)
  • expo 58.0.23, expo-asset 58.0.20, react-native 0.88.1
  • Android, Metro

Reproduction

  1. Expo SDK 58 app with NativeWind v5 (withNativewind in metro.config.js).
  2. Use NativeTabs.Trigger.Icon from expo-router/native-tabs with an md prop and install expo-symbols.
  3. Open the app on Android.

Actual

TypeError: Cannot read property 'getAssetByID' of undefined
  fromModule (node_modules/expo-asset/build/Asset.js:125)
  getAssetForSource (node_modules/expo-font/build/FontLoader.js)
  loadAsync (node_modules/expo-font/build/Font.js)
  unstable_getMaterialSymbolSourceAsync (node_modules/expo-symbols/build/materialImageSource.js)

Diagnostic in app code:

import * as RN from 'react-native';
Object.keys(RN).includes('AssetRegistry'); // false
typeof require('react-native/src/private/assets/AssetRegistry').AssetRegistry; // 'object'

Cause

src/components/index.cts is a hand-written list of getters. Comparing it with react-native/index.js (0.88.1) by name, AssetRegistry is the only export from the RN side that is missing.

Fix

Add to src/components/index.cts:

get AssetRegistry() {
  return require("react-native").AssetRegistry;
},

With this change (applied via patch-package to the commonjs and module index.cjs files as well) the Android tab icons render and the error is gone.

Suggestion

Generate the list from react-native's exports instead of maintaining it by hand, so new RN exports do not silently disappear.

Note: I did not verify this against 3.1.0-rc.1; its release notes do not mention it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions