title: React: add body class only to certain components in useEffect hook?
body: <p>I am using React 16.8.6 and hooks. I am new to hooks.</p>
  
  <p>I have a component loaded in a route I need to add a body class to.  When the user leaves this page, I need the class removed.  I am using</p>
  
  <pre><code>  useEffect(() =&gt; {
      document.body.className = 'signin';
    }, []);
  </code></pre>
  
  <p>This correctly adds the class to the body tag. Except when I navigate to another page, the class remains.  If I <strong>reload</strong> the second page it's gone.</p>
  
  <p>How do I remove the class when the component unmounts when the route changes?</p>