@logto/react 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,10 +96,7 @@ const useLogto = () => {
96
96
  }
97
97
  };
98
98
  }, [setLoadingState, handleError]);
99
- return {
100
- isAuthenticated,
101
- isLoading,
102
- error,
99
+ const methods = react.useMemo(() => ({
103
100
  getRefreshToken: proxy(client.getRefreshToken.bind(client)),
104
101
  getAccessToken: proxy(client.getAccessToken.bind(client)),
105
102
  getAccessTokenClaims: proxy(client.getAccessTokenClaims.bind(client)),
@@ -114,6 +111,12 @@ const useLogto = () => {
114
111
  // Moreover, since the location will be redirected, the isAuthenticated state will not matter any more.
115
112
  signOut: proxy(client.signOut.bind(client)),
116
113
  fetchUserInfo: proxy(client.fetchUserInfo.bind(client)),
114
+ }), [client, proxy]);
115
+ return {
116
+ isAuthenticated,
117
+ isLoading,
118
+ error,
119
+ ...methods,
117
120
  };
118
121
  };
119
122
 
@@ -1,4 +1,4 @@
1
- import { useContext, useRef, useEffect, useCallback } from 'react';
1
+ import { useContext, useRef, useEffect, useCallback, useMemo } from 'react';
2
2
  import { LogtoContext, throwContextError } from '../context.js';
3
3
 
4
4
  const useLoadingState = () => {
@@ -94,10 +94,7 @@ const useLogto = () => {
94
94
  }
95
95
  };
96
96
  }, [setLoadingState, handleError]);
97
- return {
98
- isAuthenticated,
99
- isLoading,
100
- error,
97
+ const methods = useMemo(() => ({
101
98
  getRefreshToken: proxy(client.getRefreshToken.bind(client)),
102
99
  getAccessToken: proxy(client.getAccessToken.bind(client)),
103
100
  getAccessTokenClaims: proxy(client.getAccessTokenClaims.bind(client)),
@@ -112,6 +109,12 @@ const useLogto = () => {
112
109
  // Moreover, since the location will be redirected, the isAuthenticated state will not matter any more.
113
110
  signOut: proxy(client.signOut.bind(client)),
114
111
  fetchUserInfo: proxy(client.fetchUserInfo.bind(client)),
112
+ }), [client, proxy]);
113
+ return {
114
+ isAuthenticated,
115
+ isLoading,
116
+ error,
117
+ ...methods,
115
118
  };
116
119
  };
117
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/react",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",