<MyComponent something={somethingIsTrue} />
How to add something as prop to MyComponent if somethingIsTrue? I still wouldn’t want something=undefined or something=false because it’s still been added to MyComponent. I want it to be
not added as prop
if somethingIsTrue is falsely.
>Solution :
I have yet to try this but something like this should do the trick.
const conditionalProps = shouldHaveProps ? {something: somethingIsTrue} : {};
<MyComponent {...conditionalProps} />