[IMPROVEMENT] Use class variable instead of state for List's animated (#2718)
This commit is contained in:
parent
2f3a24824f
commit
a34807d3cd
|
@ -53,20 +53,16 @@ class List extends React.Component {
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
this.needsFetch = false;
|
this.needsFetch = false;
|
||||||
this.mounted = false;
|
this.mounted = false;
|
||||||
|
this.animated = false;
|
||||||
this.state = {
|
this.state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
end: false,
|
end: false,
|
||||||
messages: [],
|
messages: [],
|
||||||
refreshing: false,
|
refreshing: false
|
||||||
animated: false
|
|
||||||
};
|
};
|
||||||
this.query();
|
this.query();
|
||||||
this.unsubscribeFocus = props.navigation.addListener('focus', () => {
|
this.unsubscribeFocus = props.navigation.addListener('focus', () => {
|
||||||
if (this.mounted) {
|
this.animated = true;
|
||||||
this.setState({ animated: true });
|
|
||||||
} else {
|
|
||||||
this.state.animated = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
console.timeEnd(`${ this.constructor.name } init`);
|
console.timeEnd(`${ this.constructor.name } init`);
|
||||||
}
|
}
|
||||||
|
@ -290,8 +286,7 @@ class List extends React.Component {
|
||||||
|
|
||||||
// eslint-disable-next-line react/sort-comp
|
// eslint-disable-next-line react/sort-comp
|
||||||
update = () => {
|
update = () => {
|
||||||
const { animated } = this.state;
|
if (this.animated) {
|
||||||
if (animated) {
|
|
||||||
animateNextTransition();
|
animateNextTransition();
|
||||||
}
|
}
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
|
Loading…
Reference in New Issue