I'm trying to put values from different TextInput's into 1 object. I'm new to React in general and don't have a firm grasp of states yet. So far my code is like this:
function App() {
const [enteredText, setEnteredText] = useState()
const [firstText, setFirstText] = useState()
const [secondText, setSecondText] = useState()
function textChange(enteredText) {
console.log(enteredText) //I want firstText and secondText here
}
return (
<View style={styles.container}>
<Text style={styles.header}>Great one!</Text>
<TextInput
value={firstText}
onChangeText={text=>setEnteredText(text)}
style={styles.input}
placeholder='1st text' />
<TextInput
value={secondText}
onChangeText={text=>setEnteredText(text)}
style={styles.input}
placeholder='2nd text' />
<Button
onPress={()=>textChange(enteredText)}
title='Submit'
color='orange' />
</View>
);
}
export default App;