Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React.memo and typescript

$
0
0

I am working on a react native app. I am currently using Item component to display data in flatlist. But editor gives me an error for the second parameter of React.memo like below.

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) => { // error here        if (prev.title === next.title) {            return true;        }    });

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>