I am currently developing a react native application. I am using the Item component within a flatlist to display data, however, I encountered an error in the editor regarding the second parameter of React.memo:
The error message reads: 'Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type '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) => { // This is where the error occurs
if (prev.title === next.title) {
return true;
}
}
);