I wan't to add a property sections: []
to my object formOpen
in the reducer, I receive my object formOpen
from my server with other properties and I want to add this one, how can I do that here ?
Thanks
import { combineReducers } from 'redux'
import * as types from '../constants/ActionTypes'
const initialState = {
isFetching: false,
formOpen: {
}
};
export function formEditor (state = initialState, action) {
switch (action.type) {
case types.RECEIVE_OPEN_FORM:
return {
...state,
isFetching: false,
formOpen: action.formOpen
};
default:
return state;
}
}
export default combineReducers({
formEditor
})
This should do the trick:
export function formEditor (state = initialState, action) {
switch (action.type) {
case types.RECEIVE_OPEN_FORM:
return {
...state,
isFetching: false,
formOpen: action.formOpen
};
case types.SET_FORM_OPEN_SECTIONS:
return {
...state,
isFetching: false,
formOpen: {
...state.formOpen,
sections: action.formOpenSections
}
};
default:
return state;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With