Skip to content

Instantly share code, notes, and snippets.

@maxsimych
Last active July 28, 2019 18:54
Show Gist options
  • Select an option

  • Save maxsimych/ff7273f89d5a2a35240993db085ca7a3 to your computer and use it in GitHub Desktop.

Select an option

Save maxsimych/ff7273f89d5a2a35240993db085ca7a3 to your computer and use it in GitHub Desktop.
condition&&expression construction JS
true && expression always evaluates to expression, and false && expression always evaluates to false.
(Therefore, if the condition is true, the element right after && will appear in the output. If it is false, React will ignore and skip it)
JSX example:
<div>
<h1>Hello!</h1>
{unreadMessages.length > 0 &&
<h2>
You have {unreadMessages.length} unread messages.
</h2>
}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment