Routes in `MaterialTopTabNavigator` are now lazy initialized like in `MaterialBottomTabNavigator`. A scene visibility is computed from multiple states and props: To handle the pan between tabs, we check if you're currently swiping between tabs and the prop `lazyOnSwipe` is true (default value) or if the tab have been already loaded, we'll check if this tab is a sibling of the focused tab. Then, we'll display the tab if it's a sibling. ~With the prop `animationEnabled` to true, we shouldn't hide a tab before the transition is done. So we're waiting `COMPLETE_TRANSITION` action to hide it. Also, if the prop `sceneAlwaysVisible` is true (default value), we won't hide scenes between A and D while transitioning.~ If the current tab has not been loaded and must not be visible, we do not render it. I'll update the docs accordingly to this PR.  <!-- #### Default behavior Tabs are lazy initialized on swipe or focus and are always visible while transitioning.  #### Hide tabs between while transitioning ```js { sceneAlwaysVisible: false, } ```  #### Fallback to only lazy initialized tabs on focus ```js { lazyOnSwipe: false, } ```  -->
React Navigation 4
Routing and navigation for your React Native apps.
Documentation can be found at reactnavigation.org.
Contributing
The project uses a monorepo structure for the packages managed by yarn workspaces and lerna. To get started with the project, run yarn in the root directory to install the required dependencies for each package:
yarn
While developing, you can run the example app with Expo to test your changes:
yarn example start
Make sure your code passes TypeScript and ESLint. Run the following to verify:
yarn typescript
yarn lint
To fix formatting errors, run the following:
yarn lint --fix
Remember to add tests for your change if possible. Run the unit tests by:
yarn test
Running the e2e tests with Detox (on iOS) requires the following:
- Mac with macOS (at least macOS High Sierra 10.13.6)
- Xcode 10.1+ with Xcode command line tools
First you need to install applesimutils and detox-cli:
brew tap wix/brew
brew install applesimutils
yarn global add detox-cli
Then you can build and run the tests:
detox build -c ios.sim.debug
detox test -c ios.sim.debug
Publishing
To publish a new version, first we need to export a GH_TOKEN environment variable as mentioned here. Then run:
yarn lerna publish
This will automatically bump the version and publish the packages. It'll also publish the changelogs on GitHub for each package.
Installing from a fork on GitHub
Since we use a monorepo, it's not possible to install a package from the repository URL. If you need to install a forked version from Git, you can use gitpkg.
First install gitpkg:
yarn global add gitpkg
Then follow these steps to publish and install a forked package:
- Fork this repo to your account and clone the forked repo to your local machine
- Open a Terminal and
cdto the location of the cloned repo - Run
yarnto install any dependencies - If you want to make any changes, make them and commit
- Now
cdto the package directory that you want to use (e.g.cd packages/stackfor@react-navigation/stack) - Run
gitpkg publishto publish the package to your repo
After publishing, you should see something like this:
Package uploaded to git@github.com:<user>/<repo>.git with the name <name>
You can now install the dependency in your project:
yarn add <user>/<repo>.git#<name>
Remember to replace <user>, <repo> and <name> with right values.