From a34807d3cdf28ef044080b9cebc1acd0e59f4f19 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 17 Dec 2020 09:56:53 -0300 Subject: [PATCH] [IMPROVEMENT] Use class variable instead of state for List's animated (#2718) --- app/views/RoomView/List.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/views/RoomView/List.js b/app/views/RoomView/List.js index fc54ee277..4db965d97 100644 --- a/app/views/RoomView/List.js +++ b/app/views/RoomView/List.js @@ -53,20 +53,16 @@ class List extends React.Component { this.count = 0; this.needsFetch = false; this.mounted = false; + this.animated = false; this.state = { loading: true, end: false, messages: [], - refreshing: false, - animated: false + refreshing: false }; this.query(); this.unsubscribeFocus = props.navigation.addListener('focus', () => { - if (this.mounted) { - this.setState({ animated: true }); - } else { - this.state.animated = true; - } + this.animated = true; }); console.timeEnd(`${ this.constructor.name } init`); } @@ -290,8 +286,7 @@ class List extends React.Component { // eslint-disable-next-line react/sort-comp update = () => { - const { animated } = this.state; - if (animated) { + if (this.animated) { animateNextTransition(); } this.forceUpdate();