You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,15 @@
2
2
React Native Router using Flux architecture
3
3
4
4
## Why I need to use it?
5
-
- Use Flux actions to push/pop screens with easy syntax like Actions.login for navigation to login screen
5
+
- Use Flux actions to replace/push/pop screens with easy syntax like Actions.login for navigation to login screen
6
6
- Forget about passing navigator object to all React elements, use actions from anywhere in your UI code.
7
7
- Configure all of your screens ("routes") once (define animations, nav bars, etc.), at one place and then just use short actions commands. For example if you use some special animation for Login screen, you don't need to code it anywhere where an user should be redirected to login screen.
8
8
- Use route "schemas" to define common property for some screens. For example some screens are "modal" (i.e. have animation from bottom and have Cancel/Close nav button), so you could define group for them to avoid any code repeatition.
9
9
- Use popup with Flux actions (see Error popup within Example project)
10
10
- Hide nav bar for some screens easily
11
11
- Use tab bars for some screens with Flux actions (see demo)
12
+
- Simplify processing of data flow in your app (see Getting Started, 4.1)
13
+
- Define your custom Flux actions (like fetch or validation actions) with the component too, so you will have all app actions in the one place.
2.1 Define Route for each app screen. Its 'type' attribute is 'push' by default, but you also could define 'replace', so navigator will replace current route with new route.
108
+
'component' attribute is React component class which will be created for this route and all route attributes will be passed to it.
109
+
'name' is unique name of Route.
110
+
2.2 If some your Routes have common attributes, you may define Schema element and just use 'schema' attribute for 'route'
111
+
2.3 If you want to define some your custom actions, just add 'Action' element inside Router. That action will not be processed by the component, it will call Actions.custom({name:ACTION_NAME, ...params}) so you could handle it in your stores. It allows to add Fetch actions (which downloads web content), etc.
112
+
3. In any app screen:
113
+
3.1 var {Actions} = require('react-native-router-flux');
114
+
3.2 Actions.ACTION_NAME(PARAMS) will call appropriate action and params will be passed to next screen.
115
+
4. In your Flux stores (optional):
116
+
4.1 You may subscribe to any push/replace/pop 'page' actions in your store.
117
+
It could be necessary if you want to process user data somehow. For example, if some component manages user form and have "Save" button which should store that data and pop the screen, you may use Actions.pop(this.state) in that component and then subscribe to Actions.pop actions within store:
0 commit comments