我有一个输入,每次我在其中输入内容时,Android 模拟器键盘都会关闭,因此如果不多次单击输入,就不可能在其中输入整个短语...
我在 Stackoverflow 中找不到与此问题相关的任何内容,有人可以帮忙吗?
代码如下:
import React, {useEffect, useState} from 'react';
import Container from "../../../components/General/Container";
import FilesList from "../../../components/Modules/Quality/FilesList";
import FilterButton from "../../../components/Modules/Quality/FilterButton";
import CategorySelector from "../../../components/Modules/Quality/CategorySelector";
import QualityApi from "../../../http/modules/quality/QualityApi";
import {Subheading, TextInput} from "react-native-paper";
import {ScrollView} from "react-native";
import {RNToasty} from "react-native-toasty";
function DocumentsScreen(props) {
const [name, setName] = useState("");
const [categories, setCategories] = useState([]);
const [selectedCategory, setSelectedCategory] = useState(null);
const [files, setFiles] = useState([]);
const [filtering, setFiltering] = useState(false);
useEffect(() => {
fetchCategories();
}, []);
function fetchCategories() {
QualityApi.getCategories()
.then(function(result) {
if (Array.isArray(result)) {
setCategories(result);
}
})
.catch(function(err) {
console.log(err)
})
}
function listFiles() {
setFiltering(true);
QualityApi.getDocuments(name, selectedCategory)
.then(function(result) {
setFiles(result);
})
.catch(function(err) {
console.log(err)
RNToasty.Error({
title: 'Ocorreu um erro ao tentar buscar os documentos.'
})
})
.finally(function() {
setFiltering(false);
})
}
function onChangeName(e) {
setName(e);
}
return(
<Container>
<ScrollView>
<CategorySelector
values={categories}
onChange={(e) => {
setSelectedCategory(e.id);
}}
selected={selectedCategory} />
<Subheading style={{fontWeight: 'bold'}}>
Nome do Arquivo
</Subheading>
<TextInput
onChangeText={(e) => onChangeName(e)}
dark={true}
value={name}
/>
<FilterButton onPress={listFiles} isLoading={filtering} />
<FilesList files={files} isLoading={filtering} />
</ScrollView>
</Container>
);
}
export default DocumentsScreen;
我也尝试将输入更改为 React Native Input 并且遇到了同样的问题。