当我的屏幕上的 InputAccessoryView 具有没有 nativeID 的组件(因此即使未显示键盘,它也会不断显示)并且我打开和关闭 Modal (反应本机模式)时,InputAccessoryView 会从屏幕上消失,并带有该组件。我不知道为什么会发生这种情况,也不知道如何将此 InputAccessoryView 保留在屏幕上。
这是重现它的代码:
import * as React from 'react';
import { View, ScrollView, AppRegistry, TextInput, InputAccessoryView, Button } from 'react-native';
import {Modal, Text, TouchableHighlight, Alert} from 'react-native';
import Constants from 'expo-constants';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {text: 'Placeholder Text', modalVisible: false,};
}
setModalVisible(visible) {
this.setState({modalVisible: visible});
}
render() {
return (
<View style={{flex:1}}>
<Modal
animationType="slide"
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {
Alert.alert('Modal has been closed.');
}}> …Run Code Online (Sandbox Code Playgroud)