I am coming across this snippet of code in the redux-connect library and I wonder is it possible to put a function as a key in the computed key in ES6. How does this work and how javascript interprets ?
export const reducer = handleActions({
[beginGlobalLoad]: state => ({
...state,
loaded: false,
}),
[endGlobalLoad]: state => ({
...state,
loaded: true,
})
....
}
with beginGlobalLoad is a function that is created by
export const beginGlobalLoad = createAction('@redux-conn/BEGIN_GLOBAL_LOAD');
I read over the concept of dynamic computed key but it does not say anything about using the function as the key for the property.
Thanks a lot for your answer
Links to the library: https://github.com/makeomatic/redux-connect/blob/master/modules/store.js