expo-asset
provides an interface to Expo's asset system. An asset is any file that lives alongside the source code of your app that the app needs at runtime. Examples include images, fonts, and sounds. Expo's asset system integrates with React Native's, so that you can refer to files with require('path/to/file')
. This is how you refer to static image files in React Native for use in an Image
component, for example. Check out React Native's documentation on static image resources for more information. This method of referring to static image resources works out of the box with Expo.Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
→
expo install expo-asset
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
import { Asset } from 'expo-asset';
number | number[]
)Downloads and stores one or more assets locally. After the assets are loaded, this hook returns a list of asset instances. If something went wrong when loading the assets, an error is returned.
Note, the assets are not "reloaded" when you dynamically change the asset list.
const [assets, error] = useAssets([require('path/to/asset.jpg'), require('path/to/other.png')]); return assets ? <Image source={assets[0]} /> : null;
Returns an array containing:
undefined
.undefined
.Name | Type | Description |
---|---|---|
hash (optional) | string | null | - |
height (optional) | number | null | - |
name | string | - |
type | string | - |
uri | string | - |
width (optional) | number | null | - |
Name | Type | Description |
---|---|---|
fileHashes (optional) | string[] | - |
fileUris (optional) | string[] | - |
hash | string | - |
height (optional) | number | - |
httpServerLocation | string | - |
name | string | - |
scales | number[] | - |
type | string | - |
uri (optional) | string | - |
width (optional) | number | - |