[英]Hide Element If It the Last Item in React
I need to hide TimelineConnector
if it is on the last item.如果它在最后一个项目上,我需要隐藏
TimelineConnector
。 How will i be able to hide it?我将如何隐藏它? Pls check my codesandbox
请检查我的代码和框
{timelines.lastIndexOf(index) !== 1 ? <TimelineConnector /> : ""}
只需与timelines
长度进行比较:
{index !== timelines.length - 1 && <TimelineConnector />}
怎么样:
{timelines.length !== (index - 1) ? <TimelineConnector /> : null}
{index < (timelines.length - 1) && <TimelineConnector />}
Simply add a check of length
with index - 1
只需添加一个带有
index - 1
的length
检查index - 1
{index - 1 != timelines.length ? <TimelineConnector /> : ""}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.