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

Popular posts from this blog

Send Data Child to Parent Component - React Js

Hide , Show and Toggle in ReactJs

Importance Of Web Content In SEO.