title: Logout link in React using Hooks
body: <p>I am using a simple boolean flag to set whether a user is logged in or out to do conditional rendering. I have doubled down with this flag to use it also as a way to logout. I am getting a TypeError that is saying my setIsLoggedIn is not a function, however I am using it in a similar way in another area of my program.</p>
  
  <p>App.js :</p>
  
  <pre><code>  const [isLoggedIn, setIsLoggedIn] = useState(false);
  
    return (
      &lt;div className="App"&gt;
        &lt;Switch&gt;
          &lt;Route
            path="/login"
            render={() =&gt; (
              &lt;Login
                isLoggedIn={isLoggedIn}
                setIsLoggedIn={setIsLoggedIn}
              /&gt;
            )}
          /&gt;
        &lt;/Switch&gt;
      &lt;/div&gt;
    );
  </code></pre>
  
  <p>A portion of the code for SignedInLinks component:</p>
  
  <pre><code>const SignedInLinks = ({ isLoggedIn, setIsLoggedIn }) =&gt; {
  
      const handleLogout = (e) =&gt; {
          e.preventDefault();
          setIsLoggedIn(false);
      }
      return (
              &lt;li&gt;&lt;NavLink to='/login' onClick={handleLogout}&gt;Logout&lt;/NavLink&gt; 
              &lt;/li&gt;
             )
  </code></pre>
  
  <p>The error is exactly 'TypeError: setIsLoggedIn is not a function'</p>