I think this is still a bug. I am using the hooks useOktaAuth and it just doesn’t work. I am on React 16.13
import React from "react";
import { useOktaAuth } from "@okta/okta-react";
const LoginButton = () => {
const { authService, authState } = useOktaAuth();
const login = async () => {
authService.login("/");
};
const logout = async () => {
authService.logout("/");
};
if (authState.isPending) {
return <div>Loading...</div>;
}
if (!authState.isAuthenticated) {
return (
<div>
<button onClick={login}>Login</button>
</div>
);
}
return (
<div>
<button onClick={logout}>Logout</button>
</div>
);
}
export default LoginButton;