0
我有bookManageReducer.jsx
:嵌套`combineReducers`不讓有狀態,而不嵌套對象
import { combineReducers } from 'redux'
import {
REQUEST_BOOKS_PAGE,
RECEIVE_BOOKS_PAGE
} from '../constants/dashboardConstants'
const books = (state = [], action) => {
switch (action.type) {
case RECEIVE_BOOKS_PAGE:
return action.books
default:
return state
}
}
const booksState = (state = {isFetching: false}, action) => {
switch (action.type) {
case REQUEST_BOOKS_PAGE:
return {isFetching: true}
case RECEIVE_BOOKS_PAGE:
return {isFetching: true}
default:
return state
}
}
// ...
const booksManageReducer = combineReducers({ books, employees, employeesList, booksPagination, booksState })
export default booksManageReducer
我想是所有中間減速根減速dashboardReducer.jsx
結合:
import { combineReducers } from 'redux'
import { routerReducer } from 'react-router-redux'
import booksManageReducer from './booksManageReducer'
const companyId = (state = {}, action) => {
return state
}
const dashboardReducer = combineReducers({booksManageReducer, companyId, routing: routerReducer})
export default dashboardReducer
哪產生這種狀態:
Object {booksManageReducer: Object, companyId: 1, routing: Object}
而不是
Object {books: [], ..., companyId: 1, routing: Object}
當我嘗試使用對象蔓延運營商:
常量dashboardReducer = combineReducers({... booksManageReducer,companyId,路由:routerReducer})
它只是從國家消失, Object.assign
也不起作用。