If you select MDN: Distribution Operator :
Distribution syntax allows you to expand an expression in places where several arguments (for function calls) or several elements (for massive literals) or several variables (for assignment of destructuring) are expected.
If you see the distribution operator inside the jsx syntax for evaluating an expression, then
<Button {...condition ? {bsStyle: 'success'} : {}} />
It would be something like (after babel run with react bootstrap example) :
_react2.default.createElement(_reactBootstrap.Button, condition ? { bsStyle: 'success' } : {})
It can also be written as:
<Button bsStyle={condition ? 'success' : ''} />
Which means that you pass the bsStyle an empty string.
So, to conditionally transfer props, you can use the spread operator and evaluate the expression. This helps us to transfer several details with the conditions:
<Button {...condition ? {bsStyle: 'success', bsSize:"large"} : {}} />
Instead
<Button bsStyle={condition ? 'success' : ''} bsSize={condition ? 'large' : ''} />
source share