【发布时间】:2020-07-25 18:30:16
【问题描述】:
如何在 React Native 中为 FlatList 的 renderItem 处理程序定义类型?
这就是我目前的处理方式:
// Importing the generic type of the FlatList render item handler
import { ListRenderItem } from "react-native";
// Associating the type to the handler
const renderItem: ListRenderItem<Bill> = useCallback(({ item }) => (
<BillCard
id={item.id}
name={item.name}
icon={item.icon}
{...}
return (
<List
data={bills}
renderItem={renderItem}
keyExtractor={(item) => String(item.id)}
/>
);
但很遗憾,这不起作用,请参阅以下错误:
【问题讨论】:
标签: reactjs typescript react-native mobile