I think instead of this:
afterLoad(origin, destination, direction) {
this.setState({
isLeaving: false,
});
bgIndex = bgArr[destination.index];
}
you should do this:
afterLoad(origin, destination, direction) {
bgIndex = bgArr[destination.index];
this.setState({
isLeaving: false,
});
}
If you change bgIndex
after the setState
call, the rerender might have already finished before bgIndex
is updated to its correct value.
Sandbox Example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…