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.

Revisions

  1. maxsimych revised this gist Jul 28, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions condition&&expression
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    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>
  2. maxsimych created this gist Jul 28, 2019.
    10 changes: 10 additions & 0 deletions condition&&expression
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    true && expression always evaluates to expression, and false && expression always evaluates to false.
    JSX example:
    <div>
    <h1>Hello!</h1>
    {unreadMessages.length > 0 &&
    <h2>
    You have {unreadMessages.length} unread messages.
    </h2>
    }
    </div>