一切似乎都还不错,我已经调试了一段时间,但似乎不明白问题出在哪里
reducers / index.js
// @flow
import { combineReducers } from "redux";
import blocks from "./blocks";
import users from "./users";
import add from "./add";
const rootReducer = combineReducers({
blocks,
users,
add
});
export default rootReducer;
reducers / add.js
// @flow
import AnyAction from "redux";
import * as ActionTypes from "./../constants";
const initialState = {
number: 0
};
export default function Add(state = initialState, action) {
switch (action.type) {
case ActionTypes.ADD:
return Object.assign({}, state, {
number: number + 1
});
default:
return state;
}
}
连接功能
const { navigation, blocks, dispatch, number } = this.props;
.
.
.
const mapStateToProps = state => ({
blocks: state.blocks,
number: state.number
});
export default connect(mapStateToProps)(BlockList);
答案 0 :(得分:1)