How to use the expo-asset.Asset.loadAsync function in expo-asset

To help you get started, we’ve selected a few expo-asset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
it('should raise an error when call with invalid argument', () => {
      // $ExpectError: first argument must be number or array if numbers
      Asset.loadAsync('');

      Asset.loadAsync([
        1,
        // $ExpectError: must be number
        '',
      ]);
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
it('should raise an error when call with invalid argument', () => {
      // $ExpectError: first argument must be number or array if numbers
      Asset.loadAsync('');

      Asset.loadAsync([
        1,
        // $ExpectError: must be number
        '',
      ]);
    });
  });
github expo / expo / apps / native-component-list / App.tsx View on Github external
async _loadAssetsAsync() {
    try {
      const iconRequires = Object.keys(Icons).map(key => Icons[key]);

      const assetPromises: Promise[] = [
        Asset.loadAsync(iconRequires),
        Asset.loadAsync(StackAssets),
        // @ts-ignore
        Font.loadAsync(Ionicons.font),
        // @ts-ignore
        Font.loadAsync(Entypo.font),
        // @ts-ignore
        Font.loadAsync(MaterialIcons.font),
        Font.loadAsync({
          'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
        }),
      ];
      if (Platform.OS !== 'web')
        assetPromises.push(
          Font.loadAsync({
            Roboto: 'https://github.com/google/fonts/raw/master/apache/roboto/Roboto-Regular.ttf',
          })
        );
github react-navigation / stack / example / App.tsx View on Github external
routeName: 'HeaderBackgroundFade',
  },
  {
    component: DragLimitedToModal,
    title: 'Drag limited to modal',
    routeName: 'DragLimitedToModal',
  },
  {
    component: StackAnimationConsumerStack,
    title: 'Stack animation consumer stack',
    routeName: 'StackAnimationConsumerStack',
  },
];

// Cache images
Asset.loadAsync(StackAssets);

class Home extends React.Component {
  static navigationOptions = {
    title: 'Examples',
  };

  _renderItem = ({ item }: { item: Item }) => (
     this.props.navigation.navigate(item.routeName)}
    />
  );

  _keyExtractor = (item: Item) => item.routeName;

  render() {
github react-navigation / tabs / example / App.tsx View on Github external
NavigationStackScreenProps,
} from 'react-navigation-stack';
import {
  Themed,
  createAppContainer,
  ThemeColors,
  useTheme,
} from 'react-navigation';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { Asset } from 'expo-asset';

import BottomTabs from './src/BottomTabs';
import MaterialTopTabs from './src/MaterialTopTabs';

// Load the back button etc
Asset.loadAsync(StackAssets);

const Home = (props: NavigationStackScreenProps) => {
  const theme = useTheme();

  return (
github EvanBacon / Lego-Expo / App.js View on Github external
async function loadResourcesAsync() {
  await Promise.all([
    Asset.loadAsync([
      require('./assets/images/robot-dev.png'),
      require('./assets/images/robot-prod.png'),
    ]),
    Font.loadAsync({
      // This is the font that we are using for our tab bar
      ...Ionicons.font,
      // We include SpaceMono because we use it in HomeScreen.js. Feel free to
      // remove this if you are not using it in your app
      'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
    }),
  ]);
}
github expo / expo / apps / native-component-list / App.tsx View on Github external
async _loadAssetsAsync() {
    try {
      const iconRequires = Object.keys(Icons).map(key => Icons[key]);

      const assetPromises: Promise[] = [
        Asset.loadAsync(iconRequires),
        Asset.loadAsync(StackAssets),
        // @ts-ignore
        Font.loadAsync(Ionicons.font),
        // @ts-ignore
        Font.loadAsync(Entypo.font),
        // @ts-ignore
        Font.loadAsync(MaterialIcons.font),
        Font.loadAsync({
          'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
        }),
      ];
      if (Platform.OS !== 'web')
        assetPromises.push(
          Font.loadAsync({
            Roboto: 'https://github.com/google/fonts/raw/master/apache/roboto/Roboto-Regular.ttf',
          })
github expo / expo / home / HomeApp.js View on Github external
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
import { Ionicons, MaterialIcons } from '@expo/vector-icons';
import url from 'url';

import './menu/MenuView';

import Navigation from './navigation/Navigation';
import HistoryActions from './redux/HistoryActions';
import SessionActions from './redux/SessionActions';
import SettingsActions from './redux/SettingsActions';
import Store from './redux/Store';
import LocalStorage from './storage/LocalStorage';
import addListenerWithNativeCallback from './utils/addListenerWithNativeCallback';

// Download and cache stack assets, don't block loading on this though
Asset.loadAsync(StackAssets);

@connect(data => App.getDataProps(data))
export default class App extends React.Component {
  static getDataProps(data) {
    let { settings } = data;

    return {
      preferredAppearance: settings.preferredAppearance,
    };
  }

  state = {
    isReady: false,
    colorScheme: Appearance.getColorScheme(),
  };
github amandeepmittal / expo-firebase / screens / Initial.js View on Github external
loadLocalAsync = async () => {
    return await Promise.all([
      Asset.loadAsync([
        require('../assets/flame.png'),
        require('../assets/icon.png')
      ]),
      Font.loadAsync({
        ...Icon.Ionicons.font
      })
    ])
  }
github wcandillon / can-it-be-done-in-react-native / season2 / bbc-iplayer / components / LoadAssets.tsx View on Github external
  usePromiseAll(assets.map(asset => Asset.loadAsync(asset)), () =>
    setReady(true)

expo-asset

An Expo universal module to download assets and pass them into other APIs

MIT
Latest version published 11 days ago

Package Health Score

89 / 100
Full package analysis