Add class to body with React
const [isOpen, setIsOpen] = useState(false)
useEffect(() => {
document.body.classList.toggle('class-open', isOpen);
},[isOpen])
<button onCLick={()=> setIsOpen(!isOpen)}>Toggle Class</button>
const [isOpen, setIsOpen] = useState(false)
useEffect(() => {
document.body.classList.toggle('class-open', isOpen);
},[isOpen])
<button onCLick={()=> setIsOpen(!isOpen)}>Toggle Class</button>