-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathApp.tsx
36 lines (34 loc) · 902 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
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import { hello, rustAdd } from "./modules/my-rust-module";
import { useEffect, useState } from "react";
export default function App() {
const [value, setValue] = useState<null | number>(null);
useEffect(() => {
async function doFetch() {
const result = await rustAdd(40, 12);
setValue(result);
}
doFetch();
}, []);
return (
<View style={styles.container}>
<Text style={styles.text}>{hello()}</Text>
<Text style={styles.text}>
{value === null ? "Loading..." : `The value is: ${value}`}
</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#FFFFFF",
alignItems: "center",
justifyContent: "center",
},
text: {
fontSize: 42,
},
});