In React JS programming we can easily render the UI components based on some conditions. Ternary operation is very useful for such conditional rendering. We can render even HTML components or CSS class names based on a given condition check.
Let understand better using an example of conditional rendering in a React App code
React JS – Conditional Rendering Example Code
![](https://smartcodehelper.com/wp-content/uploads/2021/10/image.png)
In the above example, there are two variables error and pending, both may have a boolean value true or false.
Based on the values of these variables the conditional rendering is done as seen in the code given above.