0 votes
in ReactJS by
What are inline conditional expressions?

1 Answer

0 votes
by

You can use either if statements or ternary expressions which are available from JS to conditionally render expressions. Apart from these approaches, you can also embed any expressions in JSX by wrapping them in curly braces and then followed by JS logical operator &&.

<h1>Hello!</h1>

{

    messages.length > 0 && !isLogin?

      <h2>

          You have {messages.length} unread messages.

      </h2>

      :

      <h2>

          You don't have unread messages.

      </h2>

}

Related questions

0 votes
asked Jan 31, 2021 in ReactJS by Robindeniel
0 votes
asked Jan 31, 2021 in ReactJS by Robindeniel
...