JSFiddle - React, Tailwind, and code Playground

by msfrisbie

JavaScript

let observer = new MutationObserver(() => console.log('<body> attributes changed'));

observer.observe(document.body, { attributes: true });

document.body.className = 'foo';
console.log('Changed body class');

observer.disconnect();

document.body.className = 'bar';
console.log('Changed body class again');

// Changed body class
// Changed body class again