“Toggle On Button Klik di Komponen Fungsional React JS” Kode Jawaban

Toggle On Button Klik di Komponen Fungsional React JS

const [show,setShow]=useState(true)
  return (
    <div className="App">
     {
       show?<h1>Hello World !</h1>:null
     }
<button onClick={()=>setShow(!show)} >Toggle</button> 
    </div>
  );
Difficult Dove

Kelas sakelar onklick bereaksi

import React, { useState } from "react";import "./styles.css";

export default function App() {
  const [isActive, setActive] = useState("false");
  const handleToggle = () => {
    setActive(!isActive);  };
  return (
    <div className={isActive ? "app" : null}>      <h1>Hello react</h1>
      <button onClick={handleToggle}>Toggle class</button>    </div>
  );
}
Disgusted Dingo

Jawaban yang mirip dengan “Toggle On Button Klik di Komponen Fungsional React JS”

Pertanyaan yang mirip dengan “Toggle On Button Klik di Komponen Fungsional React JS”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya