Search code examples
reactjsreact-nativenativetransitionnavigator

Is it possible to disable the transition when using Navigator.push()?


How do I disable the default transition behaviour whilst using React Native?

Here is my code:

this.props.navigator.push({
    component: view
});

Solution

  • I'm currently using the following code myself to disable transitions in certain situations when I don't want them. This comes from a discussion on the react-native repository.

    let buildStyleInterpolator = require('buildStyleInterpolator');
    
    var NoTransition = {
      opacity: {
        from: 1,
        to: 1,
        min: 1,
        max: 1,
        type: 'linear',
        extrapolate: false,
        round: 100,
      },
    };
    
    return  {
      ...Navigator.SceneConfigs.FloatFromLeft,
      gestures: null,
      defaultTransitionVelocity: 100,
      animationInterpolators: {
        into: buildStyleInterpolator(NoTransition),
        out: buildStyleInterpolator(NoTransition),
      },
    };