Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Toggle on button click in react js functional component

const [show,setShow]=useState(true)
  return (
    <div className="App">
     {
       show?<h1>Hello World !</h1>:null
     }
<button onClick={()=>setShow(!show)} >Toggle</button> 
    </div>
  );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Toggle #button #click #react #js #functional #component
ADD COMMENT
Topic
Name
3+3 =