React props object spread into component

PHOTO EMBED

Wed Jul 27 2022 11:42:41 GMT+0000 (UTC)

Saved by @Floony #react.js #javascript

var condition = true;

var props = {
  value: 'foo',
  ...(condition && { disabled: true })
};

var component = <div {...props} />;
content_copyCOPY

https://stackoverflow.com/questions/31163693/how-do-i-conditionally-add-attributes-to-react-components?rq