It's spread syntax that is being used to copy the contents of an existing style
object and then adding/overwriting a backgroundColor
property.
const styles = {
position: 'relative',
top: 0,
left: 0
};
const backgroundColor = {
background: '#FFF'
};
const newStyles = {...styles, backgroundColor };
console.log(newStyles);
// newStyles
// {
// position: 'relative',
// top: 0,
// left: 0,
// background: '#FFF'
// }
It can also be used to overwrite existing properties, but keep the others untouched:
const styles = {
position: 'relative',
top: 0,
left: 0,
background: '#222'
};
const backgroundColor = {
background: '#FFF'
};
const newStyles = {...styles, backgroundColor };
console.log(newStyles);
// newStyles
// {
// position: 'relative',
// top: 0,
// left: 0,
// background: '#FFF'
// }
So it's basically an es6 shorthand for Object.assign
.