Conditional rendering | If Condition
App.js:
import React, { useState } from 'react';
import './App.css'
function App() {
// const [loggedIn, setLoggedIn]=useState(false)
const [loggedIn, setLoggedIn]=useState(1)
return(
<div>
{
// loggedIn?<h1>Hello User</h1>:<h1>Hello Guest</h1>
loggedIn==1?<h1>Hello User 1</h1>:loggedIn==2?<h1>Hello User 2</h1>:<h1>Hello Guest</h1>
}
</div>
)
}
export default App;
Comments
Post a Comment