我是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