This is a very simple example in how to use React Navigation.
- Clone this repo
git clone https://github.com/vtisnado/react-navigation-simple-example
- Run
npm install
to install all the packages or manually install React Navigation withnpm i -S react-navigation
andnpm i -S react-native-gesture-handler
. - 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