Reputation:
how to not to pass props base on condition? I can do this
const condition = true
<ThirdPartyComponent custom={() => condition ? <h1>hello<h1> : null}
but ThirdPartyComponent will still get null, I want to skip passing custom prop to ThirdPartyComponent. Note that I don't have access to ThirdPartyComponent.
Upvotes: 0
Views: 428
Reputation: 3059
Render component on basis of condition. Using ternary operator, if true then pass prop or don't pass it on else condition
You can do like this -
const condition = true;
condition ? (<ThirdPartyComponent custom={value} />) : (<ThirdPartyComponent /> )
Upvotes: 2