
[英]Type '(text: string) => void' is not assignable to type '() => void'
[英]Type '(text: string) => void' is not assignable to type '() => any'
我正在尝试使用 reactnativeelements 中的SearchBar如下:
export function EditHash({ navigation, route }: ModifyHashProps) {
const [searchQuery, setSearchQuery] = React.useState("");
const handleSearchChange = (text: string) : void => setSearchQuery(text);
return (
<SafeAreaView>
<SearchBar
placeholder="type hashtag"
lightTheme={true}
inputContainerStyle={{
backgroundColor: "#FFFFFF",
height:30
}}
containerStyle={{
backgroundColor: "#FFFFFF",
borderWidth: 1,
borderColor: "#E5E6E6",
borderRadius: 10,
marginLeft: 20,
marginRight: 20,
}}
value={searchQuery}
onChangeText={handleSearchChange}
/>
</SafeAreaView>
);
}
不幸的是,编译器抱怨onChangeText
函数分配:
Type '(text: string) => void' is not assignable to type '((text: string) => void) & ((text: string) => void) & (() => any) & (() => any) & (() => any) & ((text: string) => void) & (() => any) & (() => any) & (() => any)'.
Type '(text: string) => void' is not assignable to type '() => any'.
根据类型定义,应该没问题:
我究竟做错了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.