admin管理员组文章数量:1429155
I work with Carousel view, and i have some dynamicaly elements, which should appear from Json list.
{
category: "Category",
code: "421313",
title: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
price: 156,
sold: false,
salePrice: false
},
As u can see i have two boolean value, and if thi value true i need to show some div element on the view.
<div className={classes.card_ceromented}>
Remended
</div>
<div className={classes.card_top_product}>
Top Product
</div>
classes.card_top_product this element i need to show hide on bollean value.
How i can show div element on true
json value?
My code: JsFiddle
I work with Carousel view, and i have some dynamicaly elements, which should appear from Json list.
{
category: "Category",
code: "421313",
title: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
price: 156,
sold: false,
salePrice: false
},
As u can see i have two boolean value, and if thi value true i need to show some div element on the view.
<div className={classes.card_ceromented}>
Remended
</div>
<div className={classes.card_top_product}>
Top Product
</div>
classes.card_top_product this element i need to show hide on bollean value.
How i can show div element on true
json value?
My code: JsFiddle
Share Improve this question asked May 25, 2021 at 11:10 AndrewAndrew 6221 gold badge6 silver badges31 bronze badges1 Answer
Reset to default 15You can do conditional rendering .
{ category.sold && (<div> This gets rendered when sold is true</div>)}
Conditional Rendering In React
本文标签: javascriptHow to showhide elements on boolean value on reactjsStack Overflow
版权声明:本文标题:javascript - How to showhide elements on boolean value on react,js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740790943a2286682.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论