我有一个按钮,当我按下它时,我想打开键盘并专注于文本输入组件。
对于最小的代码示例,我想做的就是这个-
<View>
<AddSomething
textChange={textInput => this.setState({ textInput })}
addNewItem={this.addItem.bind(this)}
textInput={this.state.textInput}
ref={not sure what goes here} //passing these as props to a text input
/>
<FloatingButton tapToAddHandler={this.onFloatingButtonPress.bind(this)} />
</View>
然后是一些用于处理按钮按下的辅助函数(this.onFloatingButtonPress)
首先如下声明您的AddSomething
: