-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
38 lines (34 loc) · 990 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { AppLoading } from "expo";
import React from "react";
import arrayFromObject from "./utils/arrayFromObject";
import cacheAssetsAsync from "./utils/cacheAssetsAsync";
import Files from "./Files";
import Game from "./Game";
/* @(Evan Bacon)
This is the base class.
Here we preload the assets and present the Game.
*/
export default class App extends React.Component {
state = { assetsLoaded: false };
componentWillMount() {
this.loadAssetsAsync();
}
loadAssetsAsync = async () => {
try {
await cacheAssetsAsync({
files: arrayFromObject(Files)
});
} catch (e) {
console.warn(
"There was an error caching assets (see: app.js), perhaps due to a " +
"network timeout, so we skipped caching. Reload the app to try again."
);
console.log(e.message);
} finally {
this.setState({ assetsLoaded: true });
}
};
render() {
return this.state.assetsLoaded ? <Game /> : <AppLoading />;
}
}