我有一个按钮,当按下它时,我希望它打开键盘并专注于文本输入组件。
对于一个最小的代码示例,我想做的是 -
<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>
Run Code Online (Sandbox Code Playgroud)
然后是一些处理按钮按下的辅助函数(this.onFloatingButtonPress)