Skip to content

authState getting null when changing the route. #289

@ksankumar

Description

@ksankumar

Describe the bug

After upgrading the react-router-dom v6 to react-router v7, getting authState null when we update the URL.

   "@okta/okta-auth-js": "^7.9.0",
    "@okta/okta-react": "^6.9.0",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "react-router": "^7.0.2",

Reproduction Steps?

const { oktaAuth, authState } = useOktaAuth()
  const location: any = useLocation()
  const authStateExists: boolean = !!authState

  useEffect(() => {
    if (!authStateExists) {
      return
    }
    if (!authState?.isAuthenticated) {
      void oktaAuth.signInWithRedirect({
        originalUri: location.pathname,
      })
    }
  }, [location, oktaAuth, authStateExists, authState?.isAuthenticated])
  console.log(authState, authState?.isAuthenticated)
  if (!authState || !authState?.isAuthenticated) {
    return <Loader />
  }

SDK Versions

System:
OS: Windows 10 10.0.19045
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13800H
Memory: 42.44 GB / 63.64 GB
Binaries:
Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
Yarn: 4.5.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
Watchman: 20240310.093207.0 - C:\ProgramData\chocolatey\bin\watchman.EXE
Browsers:
Chrome: ETM.ico
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.19041.4355
npmPackages:
@okta/okta-auth-js: ^7.9.0 => 7.9.0
@okta/okta-react: ^6.9.0 => 6.9.0
react: ^19.0.0 => 19.0.0
react-dom: ^19.0.0 => 19.0.0
react-router: ^7.0.2 => 7.0.2

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions