RN-NavigationExperimental-Redux-Example 项目教程

RN-NavigationExperimental-Redux-Example 项目教程

RN-NavigationExperimental-Redux-ExampleA small demonstration app showing how to use Redux to manage navigation state in a React Native (>0.21) application using NavigationExperimental项目地址:https://gitcode.com/gh_mirrors/rn/RN-NavigationExperimental-Redux-Example

1. 项目的目录结构及介绍

RN-NavigationExperimental-Redux-Example/
├── android/
├── ios/
├── src/
│   ├── actions/
│   ├── components/
│   ├── reducers/
│   ├── store/
│   └── index.js
├── .buckconfig
├── .flowconfig
├── .gitignore
├── .watchmanconfig
├── package.json
└── README.md
  • android/ios/:包含Android和iOS的原生代码。
  • src/:项目的源代码目录。
    • actions/:存放Redux actions。
    • components/:存放React组件。
    • reducers/:存放Redux reducers。
    • store/:存放Redux store配置。
    • index.js:项目的入口文件。
  • .buckconfig, .flowconfig, .gitignore, .watchmanconfig:配置文件。
  • package.json:项目的依赖和脚本配置。
  • README.md:项目的说明文档。

2. 项目的启动文件介绍

项目的启动文件是 src/index.js,它负责初始化React Native应用和Redux store,并将它们连接起来。

import React from 'react';
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import App from './components/App';
import configureStore from './store/configureStore';

const store = configureStore();

const RNRedux = () => (
  <Provider store={store}>
    <App />
  </Provider>
);

AppRegistry.registerComponent('RNNavigationExperimentalReduxExample', () => RNRedux);
  • Provider:将Redux store提供给React组件。
  • App:应用的根组件。
  • configureStore:配置Redux store的函数。

3. 项目的配置文件介绍

.buckconfig

Buck构建系统的配置文件。

.flowconfig

Flow类型检查工具的配置文件。

.gitignore

Git版本控制系统的忽略文件配置。

.watchmanconfig

Watchman文件监视工具的配置文件。

package.json

项目的依赖和脚本配置文件。

{
  "name": "RN-NavigationExperimental-Redux-Example",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios"
  },
  "dependencies": {
    "react": "16.0.0-alpha.6",
    "react-native": "0.44.0",
    "react-redux": "^5.0.4",
    "redux": "^3.6.0",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-jest": "19.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "19.0.2",
    "react-test-renderer": "16.0.0-alpha.6"
  },
  "jest": {
    "preset": "react-native"
  }
}
  • scripts:定义了启动和运行应用的命令。
  • dependencies:项目的生产依赖。
  • devDependencies:项目的开发依赖。
  • jest:Jest测试框架的配置。

RN-NavigationExperimental-Redux-ExampleA small demonstration app showing how to use Redux to manage navigation state in a React Native (>0.21) application using NavigationExperimental项目地址:https://gitcode.com/gh_mirrors/rn/RN-NavigationExperimental-Redux-Example

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

劳泉文Luna

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值