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.
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 /> )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.