【发布时间】:2019-09-15 19:58:34
【问题描述】:
我的应用中有这个回复按钮,当用户按下它时,它会将TextInput autoFocus 更改为true。我将 autoFocus 值设置为 false 作为默认值,并将其保持在一个状态。我看到状态将变为 true 但它没有打开键盘。
这是我的文本输入:
<TextInput
autoFocus={this.state.textInputFocus}
selectTextOnFocus={true}
ref={ref => this.textInputRef = ref}
multiline = {true}
placeholder="Write a comment ..."
onChangeText={(postComment) => this.setState({postComment})}
value={this.state.postComment} />
这是按下回复按钮时更改状态的功能:
_openReplyBox(comment_id, commenter){
this.setState({ postComment: commenter, textInputFocus: true })
}
【问题讨论】:
标签: react-native keyboard textinput autofocus