I get this error with my FlatList:
VirtualizedList: You have a large list that is slow to update - make sure your renderItem function renders components that follow React performance best practices like PureComponent, shouldComponentUpdate, etc.
My renderItem is:
renderItem(item) {
return (
<View style={[styles.item]}>
<AgendaItem item={item} />
</View>
);
}
And my component:
import React from "react";
import propTypes from "prop-types";
import { Text, View, WebView } from "react-native";
import { filterString } from "../../helpers";
const AgendaItem = ({
item: {
title,
venue,
colour,
organiser,
startTime,
endTime,
description,
allDay,
textColor
}
}) => {
let descriptionNoHtml = description.replace(/<\/?[^>]+(>|$)/g, "");
return (
<View
style={{
padding: 10,
backgroundColor: colour || "white"
}}
>
{title ? (
<Text style={{ color: textColor || "black" }}>{title}</Text>
) : null}
{description ? (
<Text style={{ color: textColor || "black" }}>
{descriptionNoHtml}
</Text>
) : null}
{venue ? (
<Text style={{ color: textColor || "black" }}>{venue}</Text>
) : null}
{organiser ? (
<Text style={{ color: textColor || "black" }}>{organiser}</Text>
) : null}
{startTime ? (
<Text style={{ color: textColor || "black" }}>
{startTime + " - " + endTime}
</Text>
) : null}
</View>
);
};
AgendaItem.propTypes = {
title: propTypes.string,
venue: propTypes.string,
colour: propTypes.string,
organiser: propTypes.string,
description: propTypes.string,
startTime: propTypes.string,
endTime: propTypes.string,
allDay: propTypes.string,
textColor: propTypes.string
};
export default AgendaItem;
How can I use shouldComponentUpdate to remove the warning?