react-navigation stack code example

Example 1: install react native navigation stack

npm install react-navigation-stack -native-community/masked-view react-native-safe-area-context

Example 2: react navigation stack

npm install -navigation/native
npm install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context -native-community/masked-view
npm install -navigation/stack

Example 3: @react-navigation/native transition like ios

import {
  CardStyleInterpolators,
  createStackNavigator,
} from '@react-navigation/stack';

const Stack = createStackNavigator();
export default () => (
  <Stack.Navigator
    screenOptions={{
      cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS
    }}
  >
    <Stack.Screen name="Screen 1" component={ScreenComponent1} />
    <Stack.Screen name="Screen 2" component={ScreenComponent2} />
  </Stack.Navigator>
);

Tags:

Dart Example