我正在开发一个反应原生应用程序。我目前正在使用 Item 组件在 flatlist 中显示数据。但是编辑器给了我一个 React.memo 的第二个参数的错误,如下所示。
输入'布尔| undefined' 不能分配给类型 'boolean'。
类型“未定义”不可分配给类型“布尔”。
const Item = React.memo(
({ icon, title }: any) => {
return (
<Box
flexDirection="row"
paddingHorizontal="l"
justifyContent="space-between"
alignItems="center"
style={{ marginTop: 35 }}
>
<Box flexDirection="row" alignItems="center" flex={1}>
{icon}
<Box marginLeft="l">
<Text variant="stackHeader">{title}</Text>
<Text
fontSize={15}
fontFamily="CrimsonRegular"
style={{ color: '#575757' }}
>
Last update: 03/06/2020
</Text>
</Box>
</Box>
<TouchableOpacity onPress={() => Clipboard.setString(title as string)}>
<FontAwesome5 name="copy" size={28} color="white" />
</TouchableOpacity>
</Box>
);
},
(prev, next) => { // error here
if (prev.title === next.title) {
return true;
}
}
);