make a fixed list in react native

Solutions on MaxInterview for make a fixed list in react native by the best coders in the world

showing results for - "make a fixed list in react native"
Giovanni
10 Jun 2016
1export default function App() {
2  const [enteredGoal,setEnteredGoal] = useState('');
3  const [courseGoals, setCourseGoals] = useState([]);
4  const goalInputHandler = (enteredText) => {
5    setEnteredGoal(enteredText);
6  }
7  const addGoalHandler = () => {
8    setCourseGoals(currentGoals => 
9      [...currentGoals,enteredGoal]
10    )
11  }
12
13  return (
14    <View style={styles.screen}>
15      <View>
16        <View style={styles.otherview}>
17          <TextInput 
18          placeholder='A goal' 
19          style={styles.textinput} 
20          onChangeText={goalInputHandler} 
21          value={enteredGoal}/>
22          <Button title='Add' onPress={addGoalHandler}/>
23        </View>
24      </View>
25        <ScrollView>
26          {courseGoals.map((goal) => 
27            <View key={goal} style={styles.listItem}>
28              <Text>{goal}</Text>
29            </View>)
30          }
31        </ScrollView>
32	</View>