React-native-router-flux: [question] track ending animation of route change

Created on 22 May 2017  路  4Comments  路  Source: aksonov/react-native-router-flux

Is there any way to track ending animation of route change? I want to render loading image during the animation and render my component when animation is completed

Router:

    <Router>
      <Scene key="root">
        <Scene key="login" component={Login} hideNavBar/>
        <Scene key="drawer" component={Drawer} open={false} type="replace" initial>
          <Scene key="main" initial navBar={Header}>
            <Scene key="search" component={Search} type="replace" initial />
            <Scene key="map" component={Map} />
          </Scene>
        </Scene>
      </Scene>
    </Router>

Button in search scene:
<Button buttonStyle={styles.button} title="map" onPress={Actions.map} />

Map component:

import MapView from 'react-native-maps';

export default class extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    return (
      <View style={styles.container}>
        <MapView
          style={styles.map}
          initialRegion={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.0922,
            longitudeDelta: 0.0421,
          }}
        />
      </View>
    );
  }
}

There is default left-to-right animation, and it slows down due to load map. I need to render map when the animation is finished.

Most helpful comment

as friends suggested to me, so you need do this

import { 
    InteractionsManager
} from 'react-native'

componentDidMount() {
  InteractionManager.runAfterInteractions(() => {
    this.setState({ ready: true })
  })
}

All 4 comments

have a similar problem...

as friends suggested to me, so you need do this

import { 
    InteractionsManager
} from 'react-native'

componentDidMount() {
  InteractionManager.runAfterInteractions(() => {
    this.setState({ ready: true })
  })
}

@konstantin-mohin, thanks for the reply. I will try this solution

@konstantin-mohin worked great for me thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarovin picture sarovin  路  3Comments

jgibbons picture jgibbons  路  3Comments

xnog picture xnog  路  3Comments

kirankalyan5 picture kirankalyan5  路  3Comments

GCour picture GCour  路  3Comments