通过ref更改inputText

问题描述 投票:0回答:1

我将通过ref更改textinput,但没有任何反应

我在渲染中的代码如下

<TextInput
       onChangeText={(value) => this.setState({replyTicketText: value})} />
       ref={"replyInput"+this.state.ticketID}
       />

当我调用该函数时:

let replyInput;
          replyInput = "replyInput"+this.state.ticketID;
          this.refs[replyInput].setNativeProps({ text: ' ' });

平台:ios

reactjs react-native
1个回答
1
投票

我可能误解了,但是将输入挂钩到状态会不会更容易,当状态改变时,字段会更新吗?

值= {this.state.replyTicketText}

© www.soinside.com 2019 - 2024. All rights reserved.