Hi Developers,
Today we are going to learn how to write ternary conditional statement
The ternary operator is a simplified conditional operator like if / else.
Syntax: condition ?:
The ternary operator is a simplified conditional operator like if / else.
Syntax: condition ?
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 - ITSolutionsGuides</h1>
<div>
{isLoading == 1 ?
<p>Value is One.</p> :
<p>Value is Another.</p>}
</div>
</div>
);
}
export default App;
---------------------------------------------------------------
Output :
Value is One
We hope it helps everyone. Thanks for supporting ITSolutionsGuides and keep supporting us also follow us in social media platforms.
Be the first to know about releases and tutorial news and solutions.
We care about your data in our privacy policy.
ITSolutionsGuides was started mainly to provide good and quality web solutions for all the developers. We provide tutorials to support all the developers and also we try to provide solutions to the errors we face while coding.
Copyright © 2023 - 2024 All rights reserved | ITSolutionsGuides