I have the following inline style object:
const simpleCarousel = {
toggle: {
....
},
toggle_prev: {
left: 0
},
toggle_next: {
right: 0
}
};
With the following standard CSS markup:
<div className="toggle, toggle_prev">Prev</div>
<div className="toggle, toggle_next">Next</div>
I want to use inline styles and combine the objects:
<div style={ Object.assign(simpleCarousel.toggle, simpleCarousel.toggle_prev) }>
Prev</div>
<div style={ Object.assign(simpleCarousel.toggle, simpleCarousel.toggle_next) }>
Next</div>
However, now toggle_prev and toggle_next both share left:0 & right:0
Question:
Short of immutable.js, in ES6/ES7 how can I combine my inline style objects immutably?
Update to Brandon request, this is not working:
<div className="controls">
<div style={ ...simpleCarousel.toggle, ...simpleCarousel.toggle_prev }>
Prev</div>
<div style={ ...simpleCarousel.toggle, ...simpleCarousel.toggle_prev }>
Next</div>
</div>
Module build failed: SyntaxError:
Ah HA!!! This works !!
<div style={ { ...simpleCarousel.toggle, ...simpleCarousel.toggle_prev } }> Prev</div>
<div style={ { ...simpleCarousel.toggle, ...simpleCarousel.toggle_next } }> Next</div>