我陷入了一个看似简单的功能。如何从 TextInput 中获取值(字符串)?
这里是代码的摘录:
const Insert = props => {
const [enteredName, setEnteredName] = useState();
const sendValues = (enteredName) => {
console.log(enteredName);
};
<TextInput
placeholder="Your Name"
blurOnSubmit
autoCorrect={false}
maxLength={30}
autoCapitalized="words"
placeholderTextColor="#777"
value={enteredName}
onChangeText={text => setEnteredSurname(text)}
/>
<View>
<Button title="Submit" onPress={sendValues(enteredName)} />
我在输入时得到了输入,但它没有提交任何内容。
有什么想法吗?
提前致谢!