Search
 
SCRIPT & CODE EXAMPLE
 

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: uuid react 
Javascript :: belle delphine 
Javascript :: Remove specific object from the Array in Javascript 
Javascript :: js scroll to bottom 
Javascript :: alphabets regex js javascript 
Javascript :: href back page javascript 
Javascript :: express js clear cookie 
Javascript :: node gitignore 
Javascript :: ajax request header laravel 
Javascript :: include partials ejs 
Javascript :: jquery get element by class and data attribute 
Javascript :: from milliseconds to hours in js 
Javascript :: javascript get current time 
Javascript :: node js for loop 
Javascript :: jquery select on select 
Javascript :: call a function when page loads javascript 
Javascript :: how to remove the parent div from the child in jquery 
Javascript :: fs check if dir is dir 
Javascript :: node js quit 
Javascript :: js get number of keys in object 
Javascript :: react js usehistory push and pass props 
Javascript :: change attribute 
Javascript :: jquery continue in loop each 
Javascript :: html string to html 
Javascript :: javascript reduce function to get sum of object value 
Javascript :: how to convert whole strig in lowercase in js 
Javascript :: js check if element into view 
Javascript :: npm ERR! code ELIFECYCLE npm ERR! errno 2 
Javascript :: jquery input text value change event 
Javascript :: js detect mobile 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =