我是redux的新手,请问下面的代码是否正确地使用了redux? 当调用执行currentTime的动作时,这是一个reducer方法。如何在使用Immutable JS映射时设置多个对象值
import { combineReducers } from 'redux';
import { UPDATE_TIME } from './actions';
import { Map } from 'immutable';
const initialState = Map({update:false, currentTime: ""});
function currentTime(state = initialState, action) {
switch (action.type) {
case UPDATE_TIME:
return {...state, update: true, currentTime: action.time };
default:
return state;
}
}
const currentTimeReducer = combineReducers({
currentTime
});
export default currentTimeReducer
感谢您的详细解答,有没有可能通过重新选择状态来做到这一点? – user2235768
你是什么意思'重新选择状态' –
http://blog.rangle.io/react-and-redux-performance-with-reselect/ – user2235768