# isAuthenticated not updated after logout

**URL:** <https://community.auth0.com/t/isauthenticated-not-updated-after-logout/57401>\
**Category:** Get Help\
**Tags:** reactjs\
**Created:** [February 5, 2021, 3:09am UTC](https://community.auth0.com/t/isauthenticated-not-updated-after-logout/57401 "2021-02-05T03:09:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raalrwai](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@raalrwai](https://community.auth0.com/u/raalrwai)\
**Post date:** [February 5, 2021, 3:09am UTC](https://community.auth0.com/t/isauthenticated-not-updated-after-logout/57401/1 "2021-02-05T03:09:56Z")

</div>

Hello, I have a component in react that I conditionally render based off isAuthenticated. This works when the app firsts load, and changes correctly after logging in. However when I log out the application still renders the part of the component it is supposed tot only render when isAuthenticated is true. How to fix this? Should I be setting the isAuthenticated to false when I click the logout button? Please help. I read something about using state to handle but could you please explain or show sample code,  
thank you in advance!

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [February 5, 2021, 3:41pm UTC](https://community.auth0.com/t/isauthenticated-not-updated-after-logout/57401/3 "2021-02-05T15:41:29Z")

</div>

Hi @raalrwai,

Would you mind sharing some of your code where you are using `isAuthenticated`?

It might be helpful to take a look at the React Quickstart if you haven’t already: [Auth0 React SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/react/01-login)

The Quickstart sample app contains this example for using `isAuthenticated`:

```auto
// src/components/NavBar.js

import React, { useState } from "react";
...
import { useAuth0 } from "@auth0/auth0-react";

const NavBar = () => {
  const {
    ...
    isAuthenticated,
    ...
  } = useAuth0();
  ...
  return (
 ...
              {isAuthenticated && (
                <NavItem>
                  <NavLink
                    tag={RouterNavLink}
                    to="/external-api"
                    exact
                    activeClassName="router-link-exact-active"
                  >
                    External API
                  </NavLink>
                </NavItem>
              )}

```

The “External API” nav link will not render unless the user is authenticated.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 20, 2021, 3:41pm UTC](https://community.auth0.com/t/isauthenticated-not-updated-after-logout/57401/4 "2021-02-20T15:41:55Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
