Skip to content

Instantly share code, notes, and snippets.

@AndreiCalazans
Created April 5, 2019 19:57
Show Gist options
  • Save AndreiCalazans/9cfb26ee714f20debfcae4f1823a16cc to your computer and use it in GitHub Desktop.
Save AndreiCalazans/9cfb26ee714f20debfcae4f1823a16cc to your computer and use it in GitHub Desktop.
function propsAreEqual(prev, next) {
return prev.isFavorite === next.isFavorite;
}
const Row = memo(({ title, isFavorite, onPress }) => {
return (
<React.Fragment>
<View style={styles.row}>
<Text style={styles.rowText}>{title}</Text>
<IconButton
color={isFavorite ? colors.heartRed : colors.darkGray}
icon="favorite"
size={18}
onPress={() => onPress(title)}
/>
</View>
<Divider />
</React.Fragment>
);
}, propsAreEqual);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment