0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

Merge pull request #1299 from logto-io/charles-bump-react-sdk-0.1.17

refactor: bump react sdk 0.1.17 and remove fetchUserInfo call
This commit is contained in:
Charles Zhao 2022-06-29 20:22:44 +08:00 committed by GitHub
commit 0568b914a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 307 additions and 122 deletions

View file

@ -18,7 +18,7 @@
"devDependencies": {
"@fontsource/roboto-mono": "^4.5.7",
"@logto/phrases": "^0.1.0",
"@logto/react": "^0.1.15",
"@logto/react": "^0.1.17",
"@logto/schemas": "^0.1.0",
"@logto/shared": "^0.1.0",
"@mdx-js/react": "^1.6.22",

View file

@ -13,7 +13,7 @@ import UserInfoSkeleton from '../UserInfoSkeleton';
import * as styles from './index.module.scss';
const UserInfo = () => {
const { isAuthenticated, fetchUserInfo, signOut } = useLogto();
const { isAuthenticated, getIdTokenClaims, signOut } = useLogto();
const api = useApi();
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const anchorRef = useRef<HTMLDivElement>(null);
@ -24,11 +24,11 @@ const UserInfo = () => {
useEffect(() => {
(async () => {
if (isAuthenticated) {
const userInfo = await fetchUserInfo();
const userInfo = getIdTokenClaims();
setUser(userInfo);
}
})();
}, [api, isAuthenticated, fetchUserInfo]);
}, [api, isAuthenticated, getIdTokenClaims]);
if (!user) {
return <UserInfoSkeleton />;

View file

@ -17,7 +17,7 @@
},
"devDependencies": {
"@logto/phrases": "^0.1.0",
"@logto/react": "^0.1.15",
"@logto/react": "^0.1.17",
"@logto/schemas": "^0.1.0",
"@logto/shared": "^0.1.0",
"@parcel/core": "2.6.2",

View file

@ -13,7 +13,7 @@ import initI18n from './i18n/init';
void initI18n();
const Main = () => {
const { isAuthenticated, fetchUserInfo, signIn, signOut } = useLogto();
const { isAuthenticated, getIdTokenClaims, signIn, signOut } = useLogto();
const [user, setUser] = useState<UserInfoResponse>();
const { t } = useTranslation(undefined, { keyPrefix: 'demo_app' });
const isInCallback = Boolean(new URL(window.location.href).searchParams.get('code'));
@ -27,13 +27,13 @@ const Main = () => {
if (isAuthenticated) {
(async () => {
const userInfo = await fetchUserInfo();
const userInfo = getIdTokenClaims();
setUser(userInfo);
})();
} else {
void signIn(window.location.href);
}
}, [fetchUserInfo, isAuthenticated, isInCallback, signIn, t]);
}, [getIdTokenClaims, isAuthenticated, isInCallback, signIn, t]);
useEffect(() => {
const onThemeChange = (event: MediaQueryListEvent) => {

File diff suppressed because it is too large Load diff