react-native 一般要用react-redux框架
简单的来说react-redux依赖redux,redux专门负责数字和逻辑管理的
而react-native只负责UI的呈现,这样对于大项目就很好的管理state
记住react-native不需要调用redux api
而react-redux需要调用redux api
写软件第一步是写导航条navigating
一般用navigator
最好是使用react-navigation
如果想达到原生应用就是react-native-navigation
navigator是直接在react-native中调用就行了
npm install --save react-navigation #save是不需要你手动修改
https://reactnavigation.org/docs/en/getting-started.html
安装详细过程:
yarn add react-navigation
# or with npm
# npm install --save react-navigation
yarn add react-native-gesture-handler
# or with npm
# npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
iOS什么都不需要做:
Android需要在android\app\src\main\java\com\qdgw中找到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);
+ }
+ };
+ }
}
npm install --save react-native-navigation
https://github.com/wix/react-native-navigation
http://www.reactnativeexpress.com/
访问:bug
http://localhost:8081/debugger-ui