MCPcopy Create free account
hub / github.com/academind/react-native-practical-guide-code / App

Function App

code/02-basics/04-handling-events/App.js:4–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
3
4export default function App() {
5 const [enteredGoalText, setEnteredGoalText] = useState('');
6
7 function goalInputHandler(enteredText) {
8 setEnteredGoalText(enteredText);
9 }
10
11 function addGoalHandler() {
12 console.log(enteredGoalText);
13 }
14
15 return (
16 <View style={styles.appContainer}>
17 <View style={styles.inputContainer}>
18 <TextInput
19 style={styles.textInput}
20 placeholder="Your course goal!"
21 onChangeText={goalInputHandler}
22 />
23 <Button title="Add Goal" onPress={addGoalHandler} />
24 </View>
25 <View style={styles.goalsContainer}>
26 <Text>List of goals...</Text>
27 </View>
28 </View>
29 );
30}
31
32const styles = StyleSheet.create({
33 appContainer: {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected