有条件地将不同的reducer加载到redux存储中

时间:2018-08-10 16:27:34

标签: javascript reactjs redux

我有一个检查用户角色的功能。我想基于将不同的reducer传递到商店中,这可能吗?

ListMultimap<V, K> output = inputMap.entrySet().stream()
        .collect(Multimaps.toMultimap(Map.Entry::getValue, Map.Entry::getKey, ArrayListMultimap::create));

我发现了一个问题,除非重新刷新,否则import { createStore, applyMiddleware } from 'redux' import thunk from 'redux-thunk' import { getUserRole } from './utils' import { composeWithDevTools } from 'redux-devtools-extension' import userReducers from './reducers' import adminReducers from './reducers/admin' //share reducer btw member and admin let reducers if (getUserRole() === 'member') { reducers = userReducers } else { reducers = adminReducers } console.log('reducers', reducers) //undefined unless I refresh the page const store = createStore( reducers, composeWithDevTools( applyMiddleware(thunk) ) ) export default store 第一次是不确定的(就像我登录一样)。

0 个答案:

没有答案