-1
日增长
8,907
stars
2,057
forks
188
watchers
737
prs
3,107
issues
53
releases
README
React Native Router (v4.x)
Follow author @PAksonov
react-native-router-flux is a different API over react-navigation. It helps users to define all the routes in one central place and navigate and communicate between different screens in an easy way. But it also means that react-native-router-flux inherits all limitations and changes from updated versions.
IMPORTANT NOTES
v5.0.alpha.x is based on React Navigation v5.x (very early alpha, development in progress, help wanted!)
v4.2.x is based on React Navigation v4.x
v4.1.0-beta.x is based on React Navigation v3.x
v4.0.x is based on [React Navigation v2.x]. See this branch and docs for v3 based on deprecated React Native Experimental Navigation API. It is not supported and may not work with latest React Native versions.
v4.0.0-beta.x is based on React Navigation v1.5.x. See this branch for this version. It is also not supported and may not work with the latest React Native versions.
---
- Examples
- Motivation
- v4 Features
- API
- Migrating from v3
- Sponsors/Backers/Contributors
Getting Started
1. Install native dependencies used by RNRF (see below, https://reactnavigation.org/docs/en/getting-started.html)
2. Install this component
sh
yarn add react-native-router-flux
install the following libraries first
1. react-native-screens by ( npm install react-native-screens || yarn add react-native-screens )
2. react-native-gesture-handler ( npm install react-native-gesture-handler || yarn add react-native-gesture-handler )
3. react-native-reanimated ( npm install react-native-reanimated || yarn add react-native-reanimated )
4. react-native-safe-area-context ( npm install react-native-safe-area-context || yarn add react-native-react-native-safe-area-context )
5. @react-native-community/masked-view ( npm install @react-native-community/masked-view || yarn add @react-native-community/masked-view )
Usage
Define all your routes in one React component...
jsx
const App = () = (
);
...and navigate from one scene to another scene with a simple and powerful API.
jsx
// Login.js
// navigate to 'home' as defined in your top-level router
Actions.home(PARAMS);
// go back (i.e. pop the current screen off the nav stack)
Actions.pop();
// refresh the current Scene with the specified props
Actions.refresh({ param1: 'hello', param2: 'world' });
API
For a full listing of the API, view the API docs.
Try the example apps
!rnrf
sh
Get the code
git clone https://github.com/aksonov/react-native-router-flux.git
cd react-native-router-flux/examples/[expo|react-native|redux]
Installing dependencies
yarn
Run it
yarn start
v4 Features
- Based on latest React Navigation API
- Separate navigation logic from presentation. You may now change navigation state directly from your business logic code - stores/reducers/etc. navigationStore
- Built-in state machine (v3 Switch replacement)
- Each Scene with component defined can have onEnter/onExitTop issues
#69Contributors wanted!78 comments · 2015-12-14#3504Unable to see tabs icons for expo app28 comments · 2019-06-28#3374this.props not receiving params25 comments · 2018-12-08#3480Passing props to previous scene20 comments · 2019-05-06#3691 currentlyFocusedField is deprecated and will be removed in a future release18 comments · 2020-07-22#3520Warning: componentWillReceiveProps is deprecated17 comments · 2019-07-16#3741For Actions.replace() and Actions.reset() animated transition is happening15 comments · 2021-03-19#3292Changed behavior of scenes into stack (always opens the first one after switching)15 comments · 2018-09-25
Latest release
4.3.1 4.3.1 2021-03-26Bug fixed: - 3741