Hello Devs,

In this tutorial, we are going to learn about react ternary conditional rendering.

Given below are few examples for react ternary conditional rendering.




Example 1:

src/App.js

import React from 'react';
import logo from './logo.svg';
import './App.css';
  
function App() {
  const isLoading = 1;
  
  return (
    <div className="container">
        <h1>React If Condition Example - Rathorji.in</h1>
  
        <div>
        {isLoading == 1 ? 
          <p>Value is One.</p> : 
          <p>Value is Another.</p>}
        </div>
    </div>
  );
}
   
export default App;


Output:

Value is One


I hope this example helps you.