Prevent layout animation after the message has already rendered

This commit is contained in:
Diego Mello 2022-12-07 16:54:24 -03:00
parent 976753c08b
commit 2683976d21
1 changed files with 3 additions and 1 deletions

View File

@ -184,9 +184,11 @@ class ListContainer extends React.Component<IListContainerProps, IListContainerS
}
if (this.mounted) {
const { messages: prevMessages } = this.state;
this.setState({ messages: data });
if (this.animated && this.viewableItems?.[0]?.index === 0) {
// animates only for new messages
if (this.animated && this.viewableItems?.[0]?.index === 0 && prevMessages[0]?.id !== data[0]?.id) {
listRef.current?.prepareForLayoutAnimationRender();
animateNextTransition();
}