score:2

Accepted answer

i have yet to try this but something like this should do the trick.

const conditionalprops = shouldhaveprops ? {something: somethingistrue} : {};

<mycomponent {...conditionalprops} />

score:1

you can make use of the dynamic expression in jsx for the desired result

<mycomponent {...(somethingistrue ? {something:somethingistrue} : {})}/>

score:1

1) you can do as:

live demo

codesandbox demo

const something = true;
const props = something ? { something: something } : null;
return <mycomponent {...props} />;

2) you can toggle component with pass argument if something is truthy

live demo

codesandbox demo

const something = true;

return something 
          ? <mycomponent something={something} /> 
          : <mycomponent />; 

Related Query

More Query from same tag