forked from holepunchto/pear-expo-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
45 lines (42 loc) · 1.1 KB
/
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
39
40
41
42
43
44
45
import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { Button, StyleSheet, Text, TextInput, View } from 'react-native';
import { reverseString } from './lib/native';
export default function App() {
const [value, setValue] = useState('')
const [reversed, setReversed] = useState(null)
return (
<View style={styles.container}>
<Text style={styles.text}>Reverse string in bare:</Text>
<TextInput style={styles.input} value={value} onChangeText={setValue}/>
<Button
onPress={() => {
reverseString(value).then(result => {
setReversed(result)
})
setValue("")
}}
title="Send"
/>
{reversed !== null && <><Text style={styles.text}>Result: {reversed}</Text></>}
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f1f1f1',
alignItems: 'center',
justifyContent: 'center',
gap: 16
},
text: {
fontSize: 16
},
input: {
width: 300,
padding: 10,
backgroundColor: '#fff'
}
});