Search code examples
reactjsreact-nativereact-navigation-stack

'transitionConfig' is removed in favor of the new animation APIs


I am working with a react native application, and it shows a warning in the console

import {createStackNavigator} from 'react-navigation-stack';
import {fromRight} from 'react-navigation-transitions';
const ApplyNowNav = createStackNavigator(
  {
    Home,
    Profile,
  },
  {
    headerMode: 'none',
    transitionConfig: () => fromRight(),
  }
);

WARN Deprecation in 'createStackNavigator':

transitionConfig' is removed in favor of the new animation APIs

Is there any solution to fix this issue?


Solution

  • You need to update your code to use to use the new Animation API: https://reactnavigation.org/docs/en/stack-navigator.html#animations

    From the code you posted, you can change it to the following instead to have a slide from right animation:

    import { createStackNavigator, TransitionPresets } from 'react-navigation-stack';
    
    const ApplyNowNav = createStackNavigator(
      {
        Home,
        Profile,
      },
      {
        headerMode: 'none',
        defaultNavigationOptions: {
          ...TransitionPresets.SlideFromRightIOS,
        },
      }
    );