[IMPROVEMENT] Use class variable instead of state for List's animated (#2718)

This commit is contained in:
Diego Mello 2020-12-17 09:56:53 -03:00 committed by GitHub
parent 2f3a24824f
commit a34807d3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -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();