Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

javascript - how to display a div with multiple conditions in reactjs

I am trying to display a div according to some condition but it is not working properly. i have some user like admin and visitor and some more profile, and there is one more condition associated with admin let take that condition isBusy(boolean).

i want to display particular div only for admin and visitor. and for admin when isBusy is true here is my code-

{(user.isAdmin() && this.props.isBusy) || user.isVisitor() &&
<div>
some more code
</div>
}

i want to show this div when user is admin and isBusy = true or user is visitor. these conditions are not working properly.

Thanks in advance

question from:https://stackoverflow.com/questions/65951647/how-to-display-a-div-with-multiple-conditions-in-reactjs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your mistake in brackets, see example for details CodeSandbox example


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...