-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp2.tsx
51 lines (44 loc) · 1.48 KB
/
App2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { StyleSheet, Text, View, Button, Alert, TextInput } from "react-native";
import AppFooter from "./components/AppFooter";
import AppHeader from "./components/AppHeader";
import Content from "./components/Content";
import { stylesPractice } from "./styles/styles";
import { useEffect, useState } from "react";
export default function App(): React.JSX.Element {
const [fullname, setFullname] = useState("");
const [message, setMessage] = useState("Message from App.tsx");
const [footerMessage, setFooterMessage] = useState(
"Thai-Nichi-Institute of Technology"
);
useEffect(() => {
console.log("Component has mounted");
}, []);
// This runs whenever the fullname changes
useEffect(() => {
console.log(` Fullname has changed to: ${fullname}`);
}, [fullname]);
const handleButtonClick = () => {
Alert.alert(`Hello, Input your fullname: ${fullname}`);
}
return (
<View style={styles.container}>
<AppHeader fullname={fullname} message={message} />
{/* <Content message={message} fullname={fullname} /> */}
<Content message={message} onButtonClick = {handleButtonClick} />
<TextInput
style={stylesPractice.input}
placeholder="Enter your fullname"
value={fullname}
onChangeText={setFullname}
/>
<AppFooter footerMessage={footerMessage} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#eee",
justifyContent: "flex-start"
},
});