-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
27 lines (21 loc) · 840 Bytes
/
App.js
File metadata and controls
27 lines (21 loc) · 840 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
import React, { useState, useEffect } from "react";
import {View, Button, Text} from "react-native";
function App() {
const [count, setCount] = useState(0);
useEffect(() => {
console.log(`You have clicked the first button ${count} times`);
}, [count]);
const [count2, setCount2] = useState(0);
useEffect(() => {
console.log(`You have clicked the second button ${count2} times`)
}, [count2]);
return (
<View style={{flex:1, alignItems:'center', justifyContent:'center', backgroundColor:'#8FBDD3' }}>
<Text style={{fontSize:26}}>React Native ~ useEffect{'\n'}</Text>
<Button color="#BE8C63" title="Click Me" onPress={() => setCount(count + 1)}/>
<Text>{'\n'}</Text>
<Button color="#A97155" title="Click Me" onPress={() => setCount2(count2 + 1)} />
</View>
);
}
export default App;