【发布时间】:2021-07-17 16:31:13
【问题描述】:
Instagram 克隆:
我想检查我是否关注了我的关注者然后显示<button>unfollow</button> 或者如果不显示<button>follow</button>
var IfollowAndHeFollowMe;
myfollowers.map(follower => {
return(
<div>
<div>{follower.userName}</div>
{ IfollowAndHeFollowMe =
myfollowings.filter((following) => following.userName == follower.userName)
}
// this doesn't work
{ IfollowAndHeFollowMe.length > 0 ? return( <button>unfollow</button>): return(<button>follow</button>) }
// and this also doesn't work
{ return IfollowAndHeFollowMe.length > 0 ? <button>unfollow</button> : <button>follow</button>}
</div>
)
})
//https://instagram-app-clone.netlify.app/ --- 仅适用于手机 ---
【问题讨论】:
标签: javascript html reactjs jsx