Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react toggle class

  
// You Should pass props to main functions and import useState
const [isActive, setActive] = useState(false);
const toggleClass = () => {
    setActive(!isActive);
  };

<YouDiv ClassName="{isActive ? 'active': null}" onClick={toggleClass}>
 
</YouDiv>
 
PREVIOUS NEXT
Tagged: #react #toggle #class
ADD COMMENT
Topic
Name
1+8 =