npm.io
0.87.0 • Published 1 week ago

@react-native/assets-registry

Licence
MIT
Version
0.87.0
Deps
0
Size
8 kB
Vulns
0
Weekly
0
Stars
126.1K

@react-native/assets-registry

npm package

This package is deprecated (since 0.87) and will be removed in a future release. Use AssetRegistry from react-native (or the react-native/asset-registry build entry point) instead of @react-native/assets-registry/registry, and @react-native/asset-utils instead of @react-native/assets-registry/path-support.

Runtime registry that maps asset IDs generated in a Metro bundle to asset metadata. It backs <Image>, Image.resolveAssetSource(), and any code that resolves require('./img.png') on native.

Most apps never import this directly — assets are handled through <Image>.

API

@react-native/assets-registry/registry (DEPRECATED)

Deprecated: Aliases to AssetRegistry (since 0.87).

Please use:

  • import { AssetRegistry } from 'react-native'; (apps/library code)
  • 'react-native/asset-registry' (entrypoint for Metro/build configs)
Export Signature Notes
registerAsset (asset: PackagerAsset) => number Stores the asset; returns a numeric ID
getAssetByID (assetId: number) => PackagerAsset Looks an asset back up by ID
@react-native/assets-registry/path-support (DEPRECATED)

Deprecated: Use @react-native/asset-utils (since 0.87).

Android resource-path helpers, used when copying assets into drawable-* folders.

Export Signature Notes
getAndroidResourceFolderName (asset: PackagerAsset, scale: number) => string e.g. drawable-xhdpi; non-drawable types resolve to raw
getAndroidResourceIdentifier (asset: PackagerAsset) => string Sanitised resource name
getBasePath (asset: PackagerAsset) => string httpServerLocation without the leading slash

Keywords