title: useEffect does not listen for localStorage
body: <p>I'm making an authentication system and after backend redirects me to the frontend page I'm making API request for userData and I'm saving that data to localStorage. Then I'm trying to load Spinner or UserInfo.</p>
  <p>I'm trying to listen for the localStorage value with useEffect, but after login I'm getting 'undefined'. When the localStorage value is updated useEffect does not run again and Spinner keeps spinning forever.</p>
  <p>I have tried to do: <code>JSON.parse(localStorage.getItem('userData'))</code>, but then I got a useEffect infinite loop.</p>
  <p>Only when I'm refreshing the page does my localStorage value appear and I can display it instead of Spinner.</p>
  <p>What I'm doing wrong?</p>
  <p>Maybe there is a better way to load userData when it's ready?</p>
  <p>I'm trying to update DOM in correct way?</p>
  <p>Thanks for answers ;)</p>
  <pre><code>import React, { useState, useEffect } from 'react';
  import { Spinner } from '../../atoms';
  import { Navbar } from '../../organisms/';
  import { getUserData } from '../../../helpers/functions';
  
  const Main = () =&gt; {
    const [userData, setUserData] = useState();
    useEffect(() =&gt; {
      setUserData(localStorage.getItem('userData'));
    }, [localStorage.getItem('userData')]);
  
    return &lt;&gt;{userData ? &lt;Navbar /&gt; : &lt;Spinner /&gt;}&lt;/&gt;;
  };
  
  export default Main;
  </code></pre>