-
Notifications
You must be signed in to change notification settings - Fork 295
Closed
Labels
Description
It was really surprising for me that createActions can handle nested objects while handleActions can't. I think this example looks very natural and readable:
const defaultState = {
query: undefined
}
export const actionCreators = createActions({
SEARCH: {
SET_QUERY: text => text,
}
})
export const reducer = handleActions({
SEARCH: {
SET_QUERY: (state = defaultState, action = {}) => {
return {...state, query: action.payload}
},
},
}, defaultState)But it doesn't work. Instead reducer must be:
export const reducer = handleActions({
'SEARCH/SET_QUERY': (state = defaultState, action = {}) => {
console.log('reducer.search.setQuery <-', state, ',', action)
return {...state, query: action.payload}
},
}, defaultState)My IDE autocompletes with first example and doesn't with the second.
Would it be possible to allow such nested structures in handleActions?
manolkalinov and Vincz