A React Native starter powered by dva and react-navigation
npm install dva-native-cli -g
dvanative git app
cd app
react-native run-ios # or react-native run-android
Great thanks to @xuan45 for his cli tool dva-native-cli, check that project for more information.
The builtin router of dva (not react-router v4), doesn't support React Native, we have to integrate other router components, such as Navigator, ExperimentalNavigation, react-native-router-flux and react-navigation. Since the former two will be depreciated in flavor of react-navigation, which is also be recommended by official, so I choose it to be the navigator.
In this starter, I provide a router model to control the default action flow of react-navigation to workaround a known issue. If you don't need this, the integration will be much simpler, you can simply remove the router model and pass routerReducer to extraReducer of dva extraReducers: { router: routerReducer }
. Read Redux Integration and dva's API for more information.
Also there is another workaround for a missing feature react-navigation/react-navigation#232, so I use two StackNavigators to contain the screens with different transition animations, you can create you own transition animations via transitionConfig, see react-navigation/react-navigation#99
1.错误的使用dva-no-router,这是react项目使用的,并不适用于rn,改用dva-core + react-redux 2.解构失败: const value = ({}) => { ... } 是不允许的, 会报错
ReactNativeJS: 'Unhandled promise rejection', { [TypeError: undefined is not a function (evaluating 'babelHelpers.objectDestructuringEmpty(r)')]
Could not install the app on the device, read the error above for details.Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
解决办法: 在根目录下运行:chmod 755 android/gradlew 然后就解决了
MIT