我正在使用 React Native0.57.8
和 React 16.7.0
。我正在为 Android TV 创建一个屏幕键盘,它将用作库。我有一个TextInput
我已分配给他参考的人。我如何使用这个引用改变value
的TextInput
?
constructor(props) {
super(props);
this.emailRef = React.createRef();
}
<TextInput
ref={this.emailRef}
placeHolder="Email Address"
blurOnSubmit={false}
/>
<Keyboard textInput={this.emailRef} />
图书馆内部:
<Button
text="change value"
onPress={() => {
this.props.emailRef.current.props.value =
this.props.emailRef.current.props.value + "q";
}}
/>