Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

toggle in react

// Toggle in react 
const [show, setShow] = useState();

  const ToggleData = () => {
    setShow(!show);
  };

  return (
    <div className="App">
      <button onClick={ToggleData}> {!show ? "Show" : 'Dont"t show'} </button>
      {show ? <h1> Show </h1> : <h1>Don't Show </h1>}
    </div>
       
       
 
PREVIOUS NEXT
Tagged: #toggle #react
ADD COMMENT
Topic
Name
5+6 =