I have the following initial state that consists of flat properties and one deep nested property searchStatus
:
var searchStatus = Immutable.fromJS({
requesting: {
component: {tenants: false, platforms: false},
tenant: false,
hdf: false,
cluster: false
}
});
const initialState = {
selectedItem: null,
searchQuery: '',
searchStatus: searchStatus
};
I have a reducer that works with this state:
function reducer(state = initialState, action) {
switch (action.type) {
case GET_TENANT_TEMPLATES_LISTING_REQUEST:
var status = state.searchStatus.updateIn(['requesting', 'component', 'tenants'], function () {
return true;
});
return assign({}, state, {
searchStatus: status
});
Is it OK to return new copy only for searchStatus
part of the state and then merge it into the state or should I always return the entire state copy?
UPDATE:
case GET_TENANT_TEMPLATES_LISTING_REQUEST:
var copy = assign({}, state);
copy.searchStatus.requesting.component.tenants = true;
return copy;