I saw a JS syntax as following:
export const ChartComponent = props => {
const {
data,
colors: {
backgroundColor = 'white',
lineColor = '#2962FF',
textColor = 'black',
areaTopColor = '#2962FF',
areaBottomColor = 'rgba(41, 98, 255, 0.28)',
} = {}, // what is that curly brace?
} = props;
...
}
I've read the destructuring assignment, but I still don't know what the curly braces do?
It seems a default value for colors, but I don't know why.
As far as I know:
- the syntax only assigns destructuring values to
data/backgroundColor/lineColor/textColor/areaTopColor/areaBottomColor, not includingcolors. - The destructuring variables (
backgroundColor/lineColor/textColor/areaTopColor/areaBottomColor) already have their own default values.
Is the curly braces for color necessary? What does it do?