- if conditions or operator to create an element
-
Variable elements
- The AND operator &&
JavaScript, true && expression
always will return expression
, and false && expression
will always return false
.
Therefore, if the conditions true
, &&
the elements on the right side will be rendered, if it is false
, React ignore and skip it.
-
Ternary operator
- Prevent component rendering
In the component of render
the return process null
and will not affect the life cycle of components. For example, the above example, componentDidUpdate
will still be called