Hide , Show and Toggle in ReactJs
App.js:
import React, {useState} from 'react';
import './App.css'
function App()
{
const [show, setShow]=useState(true)
return(
<div>
{
show?<h1>Hello Bhavesh</h1>:null
}
{/* <button onClick={()=>setShow(false)}>Hide</button>
<button onClick={()=>setShow(true)}>Show</button> */}
<button onClick={()=>setShow(!show)}>Toggle</button>
</div>
)
}
export default App;
Comments
Post a Comment