authState is null after redirecting to login/callback in React

i am using okta with React after redirecting to login/callback authState is null.

@sarmad Which sdk package you are using now? Can you pls add the link of the sdk as well as the error pic?

@okta/okta-auth-js”: “^5.2.2”,
@okta/okta-react”: “^6.0.0”,

These are the two Libraries i am using and below is my code for signInWithRedirect. it lets me sign in successfully but authState is throwing null after sign in so i cannot set the state and check if user is authenticated or not.

import { useOktaAuth, withOktaAuth } from "@okta/okta-react";
import React, { useState, useEffect } from "react";
import { OktaAuth } from "@okta/okta-auth-js";
import { Link } from "react-router-dom";
import { useHistory } from "react-router-dom";

const OktaSignInWidget = (props) => {
  const { authState, oktaAuth } = useOktaAuth();

  const [userInfo, setUserInfo] = useState(null);
  const history = useHistory();
  const login = async () => {
    oktaAuth.signInWithRedirect();
  };
      // oktaAuth.signOut();
  
  useEffect(() => {
    console.log(props, authState);
    ( async () => {
      const tokens = await oktaAuth.token.getWithoutPrompt();
      const user = await oktaAuth.getUser(tokens.tokens);
      console.log("user ==>", user);
      console.log(tokens)
      oktaAuth.tokenManager.setTokens(tokens);
      props.receiveTokens(
        tokens.tokens.accessToken.accessToken, 
        tokens.tokens.idToken.idToken,
        );
    })();
  }, []);
  return (
    <Link
      onClick={(e) => {
        e.preventDefault();
        login();
      }}
    >
      {" "}
      Sign In With Okta{" "}
    </Link>
  );
};
export default OktaSignInWidget;

You may want to update to AuthJS v5.2.3. We released it the other week to help with issues with the authState