-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
32 lines (28 loc) · 923 Bytes
/
App.js
File metadata and controls
32 lines (28 loc) · 923 Bytes
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
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
export default function App() {
const [name, setName] = useState('Abhinav');
const [person, setPerson] = useState({ name: 'Tushar', age: 22 });
const clickHandler = () => {
setName('Prem');
setPerson({ name: 'Edward', age: 24 });
};
return (
<View style={styles.container}>
<Text style={{fontSize:26}}>React Native ~ useState{'\n'}</Text>
<Text style={{fontSize:20}}>My name is {name}.</Text>
<Text style={{fontSize:20}}>His name is {person.name} and his age is {person.age}.{'\n'}</Text>
<View>
<Button color="#92BA92" title='update state' onPress={clickHandler}/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F1DDBF',
alignItems: 'center',
justifyContent: 'center',
}
});