Cap the number of renderable messages to increase performance
This commit is contained in:
@@ -212,6 +212,9 @@ export default class Chat extends Component {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
updatedMessageList.splice(insertAtIndex + 1, 0, convertedMessage);
|
updatedMessageList.splice(insertAtIndex + 1, 0, convertedMessage);
|
||||||
|
if (updatedMessageList.length > 300) {
|
||||||
|
updatedMessageList = updatedMessageList.slice(Math.max(updatedMessageList.length - 300, 0));
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
messages: updatedMessageList,
|
messages: updatedMessageList,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user