Skip to content

求教:modules里面怎么获取大的state啊 #74

Description

@volcanG

代码结构是这样

--src\routes\Subscribe\index.js
const container = require('./containers/SubscribeContainer').default const reducer = require('./modules/Subscribe').default /* Add the reducer to the store on key 'counter' */ injectReducer(store, { key: 'subscribe', reducer })

--\src\routes\Subscribe\modules\Subscribe.js
[SUBSCRIBE_CHANGE_VIEW]: (state) => { console.info('-----------debug------------------') console.info(state) return { ...state, showStyle: state.showStyle === 'table' ? 'view' : 'table' } }

--\src\store\reducers.js
`import { combineReducers } from 'redux'
import locationReducer from './location'
import navBarReducer from '../components/NavBar/modules/NavBar'
import loginReducer from '../components/Login/modules/Login'

export const makeRootReducer = (asyncReducers) => {
return combineReducers({
navbar:navBarReducer,
location: locationReducer,
DATA:loginReducer,
...asyncReducers
})
}

export const injectReducer = (store, { key, reducer }) => {
store.asyncReducers[key] = reducer
store.replaceReducer(makeRootReducer(store.asyncReducers))
}

export default makeRootReducer`

--\src\components\Login\modules\Login.js
const ACTION_HANDLERS = { [LOGIN_FETCH_SUCCESS]: (state, action) => { return ({ ...action.payload }) } }

业务逻辑是这样,登录成功将获取的数据放入大的state(modules\Login.js),然后modules\Subscribe.js需要处理这个大的state.
modules里面怎么获取大的state啊,modules\Subscribe.js reducer 处理只能获取到当前的key('subscribe')下得state状态,怎么获取大的state 的属性值啊,我想获取DATA。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions