aushion / RNCNode

React-Native 版 CNode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

步骤

import {
  combineReducers // 将顶层 state 改造为 immutable 对象
} from 'redux-immutable'
const rootReducer = combineReducers({
  topic
})

2、创建 store 时以 Immutable.Map 初始化 store

store = createStore(
    rootReducer,
    Immutable.Map({}),
    compose(
      __DEV__
        ? composeWithDevTools({})(applyMiddleware(...middlewares))
        : applyMiddleware(...middlewares)
    )
  )

3、state 中的每一项都用Immutable对象或者数组初始化

export const topic = handleActions(
  {
    [getTopicByTabNameAction](state, { payload }) {
      ...
    },
    [clearTopicAction]() {
      ...
    }
  },
  defaultMap
)

const defaultMap = Immutable.Map({
  all: Immutable.List(),
  share: Immutable.List(),
  job: Immutable.List(),
  good: Immutable.List(),
  ask: Immutable.List()
})

遇到的问题

  • 用 Android studio 跑项目时,有个 error: Please select android sdk 点进去重写下载一波依赖就 OK
  • 引入ts 时,import React from 'react'; 报错 增加配置:"allowSyntheticDefaultImports":true
  • react-navigation 使用注意: 显式渲染多个 navigator

About

React-Native 版 CNode


Languages

Language:JavaScript 50.8%Language:TypeScript 35.6%Language:Objective-C 5.9%Language:Python 4.9%Language:Java 2.8%