Export assets for easy caching in Expo

This commit is contained in:
Brent Vatne 2018-10-15 13:17:12 -07:00
parent a69a4e3c04
commit 0ad814c529
2 changed files with 17 additions and 8 deletions

View File

@ -1,8 +1,11 @@
import React from 'react';
import Expo from 'expo';
import { FlatList, I18nManager } from 'react-native';
import { createSwitchNavigator } from '@react-navigation/core';
import { createStackNavigator } from 'react-navigation-stack';
import { createSwitchNavigator } from 'react-navigation';
import {
Assets as StackAssets,
createStackNavigator,
} from 'react-navigation-stack';
import { ListSection, Divider } from 'react-native-paper';
import SimpleStack from './src/SimpleStack';
@ -41,12 +44,8 @@ const data = [
},
];
Expo.Asset.loadAsync(
require('react-navigation/src/views/assets/back-icon.png')
);
Expo.Asset.loadAsync(
require('react-navigation/src/views/assets/back-icon-mask.png')
);
// Cache images
Expo.Asset.loadAsync(StackAssets);
class Home extends React.Component {
static navigationOptions = {

View File

@ -1,4 +1,5 @@
/* eslint-disable import/no-commonjs */
import { Platform } from 'react-native';
module.exports = {
/**
@ -11,6 +12,15 @@ module.exports = {
/**
* Views
*/
get Assets() {
return Platform.select({
ios: [
require('./views/assets/back-icon.png'),
require('./views/assets/back-icon-mask.png'),
],
android: [require('./views/assets/back-icon.png')],
});
},
get Header() {
return require('./views/Header/Header').default;
},