Use the same screen navigation animation both on Android/iOS with React Native + React Navigation
Kay Gosho

Kay Gosho @acro5piano

About: A Full Stack Developer. CTO of Remotehour ( https://remotehour.com )

Location:
Tokyo, Japan
Joined:
Feb 1, 2018

Use the same screen navigation animation both on Android/iOS with React Native + React Navigation

Publish Date: Aug 28 '19
9 3

React Navigation's default screen navigation on Android looks strange, because it creates modals even if "swipe to left" closes the modal:

image

I would like the animation to slide from left to right in the same way on iOS:

The solution is very simple:



import {
  createAppContainer,
  createStackNavigator,
  StackViewTransitionConfigs,
} from 'react-navigation'

const Navigation = createStackNavigator({
  screenA: ComponentA,
  screenB: ComponentB,
}, {
  mode: 'card',
  transitionConfig: () => StackViewTransitionConfigs.SlideFromRightIOS,
}

export const AppNavigation = createAppContainer(Navigation)


Enter fullscreen mode Exit fullscreen mode

I wonder why this is the default behavior...

Ref

https://stackoverflow.com/questions/48018666/how-to-change-the-direction-of-the-animation-in-stacknavigator

Comments 3 total

  • Nicolas Pavlotsky
    Nicolas PavlotskyDec 4, 2019

    This works! But is there any way to implement swipe back?

    • Kay Gosho
      Kay GoshoDec 11, 2019

      Thank you for your comment.
      If you set gesturesEnabled: true in stack navigation config swipe back will be enabled, which is the default settings.

  • Jorge Suarez
    Jorge SuarezSep 18, 2020

    do you if for @react-navigation/bottom-tabs works?

Add comment