I have some confusion about using Object.assign
for React and Redux.
I read this article.
It says ES6 Does not supported by all browsers but I have started using it.
I have two questions:
- Is it the right decision to continue with
Object.assign
? - What is the alternative?
My Code
export const selectDiameter = (scaleData, size) => {
return {
type: SELECT_DIAMETER,
payload: Object.assign({}, scaleData, {
diameter: Object.assign({}, scaleData.diameter, {
selected_tube_diameter: size,
is_clicked: true,
audio: Object.assign({}, scaleData.diameter.audio, {
is_played: true
})
})
})
}
}
What is the alternative for the above code?
Object.assign
redux.js.org/docs/recipes/UsingObjectSpreadOperator.htmlselectedTubeDiameter
instead of snake-caseselected_tube_diameter
. It doesn't make any sense to useObject.assign
when you're just dumping stuff into an empty object you control anyway.