<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.
I have yet to try this but something like this should do the trick.
const conditionalProps = shouldHaveProps ? {something: somethingIsTrue} : {};
<MyComponent {...conditionalProps} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With