每当我单击一个选项时,我都希望文本输入被清除 我试过实现 clearbuttonmod 但它不起作用
tcpdump -n -i ens224 not stp
答案 0 :(得分:1)
在顶部,导入 useRef
import {useRef} from "react";
创建一个 ref
变量并在 TextInput
中使用它
const InputRef = useRef();
然后在 TextInput
<TextInput
style={styles.input}
ref={InputRef}
clearButtonMode="always"
placeholder="Report..."
onChangeText={(value) => setValue(value)}
/>
单选按钮中的广告
<RadioButton.Group
onValueChange={(value) => {
setValue(value)
InputRef.current.clear()
}}
value={value}
>