-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
39 lines (33 loc) · 980 Bytes
/
App.tsx
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
39
import { StatusBar } from "expo-status-bar";
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View } from "react-native";
import { ASSET } from "./src/type/type";
import axios from "axios";
import AppNavigator from "./src/navigation/AppNavigator";
export const globalStateContext = React.createContext<ASSET[]>(undefined!);
export default function App() {
const [assets, setAssets] = useState<ASSET[]>([]);
useEffect(() => {
axios
.get("https://assets-api.sylo.io/v2/all?take=20&has_history_only=true")
.then((response) => {
setAssets(response.data);
})
.catch((error) => {
console.log(error);
});
}, []);
return (
<globalStateContext.Provider value={assets}>
<AppNavigator />
</globalStateContext.Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});