const BUTTON_TYPE_CLASSES = {
base : 'base',
inverted : 'inverted'
}
const getButton = (buttonType) =>
({
[BUTTON_TYPE_CLASSES.base] : BaseComponent,
[BUTTON_TYPE_CLASSES.inverted] : InvertedComponent,
}[buttonType]);
I understand what this code blocks mean. But I don't know what works brackets in object of function getButton.
Why don't use just BUTTON_TYPE_CLASSES.base : BaseComponent... ? Why use [BUTTON_TYPE_CLASSES.base] : BaseComponent... ?