make a fixed list in react native
export default function App() {
const [enteredGoal,setEnteredGoal] = useState('');
const [courseGoals, setCourseGoals] = useState([]);
const goalInputHandler = (enteredText) => {
setEnteredGoal(enteredText);
}
const addGoalHandler = () => {
setCourseGoals(currentGoals =>
[...currentGoals,enteredGoal]
)
}
return (
<View style={styles.screen}>
<View>
<View style={styles.otherview}>
<TextInput
placeholder='A goal'
style={styles.textinput}
onChangeText={goalInputHandler}
value={enteredGoal}/>
<Button title='Add' onPress={addGoalHandler}/>
</View>
</View>
<ScrollView>
{courseGoals.map((goal) =>
<View key={goal} style={styles.listItem}>
<Text>{goal}</Text>
</View>)
}
</ScrollView>
</View>
Also in JavaScript:
- es6 compare two arrays
- react convert excel to json
- jquery get current url
- remove all mutliple items from array javascript
- jquery on body click
- javascript get first 2 char
- install nuxt js
- how to remove key value pair from object in javascript
- for loop javascript
- how to get the square root in js
- calculate time difference in javascript
- javascript remove element
- prepend javascript
- what is code.jquery integrity crossorigin
- js set important style
- arrow keys function javascript
- add bootstrap to gatsby
- stripe stripe js
- onclick on non button
- array remove empty entrys js
- javascript get Time
- jQuery get selected option
- multiple case switch javascript
- vue v-for object