Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.62 KB

README.md

File metadata and controls

43 lines (33 loc) · 1.62 KB

react-navigation-simple-example

This is a very simple example in how to use React Navigation.

How to run

  1. Clone this repo git clone https://github.com/vtisnado/react-navigation-simple-example
  2. Run npm install to install all the packages or manually install React Navigation with npm i -S react-navigation and npm i -S react-native-gesture-handler.
  3. You also need to link dependencies with react-native link react-native-gesture-handler

No additional steps are required for iOS.

To finalise installation of react-native-gesture-handler for Android, be sure to make the necessary modifications to MainActivity.java:

package com.reactnavigation.example;

import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

  @Override
  protected String getMainComponentName() {
    return "Example";
  }

+  @Override
+  protected ReactActivityDelegate createReactActivityDelegate() {
+    return new ReactActivityDelegate(this, getMainComponentName()) {
+      @Override
+      protected ReactRootView createRootView() {
+       return new RNGestureHandlerEnabledRootView(MainActivity.this);
+      }
+    };
+  }
}

Always check the latest changes in the official documentation: https://reactnavigation.org/docs/en/getting-started.html

Alt text Alt text