-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
39 lines (37 loc) · 1.02 KB
/
App.tsx
File metadata and controls
39 lines (37 loc) · 1.02 KB
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 { StyleSheet, Text, View } from "react-native";
import { hello, rustAdd } from "./modules/rust-module";
import { useEffect, useState } from "react";
export default function App() {
const [value, setValue] = useState<null | number>(null);
useEffect(() => {
console.log("Calling rustAdd...");
async function doFetch() {
console.log("Fetching value from Rust...");
const result = await rustAdd(40, 12);
console.log("Received value from Rust:", result);
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,
},
});