@frontegg/react-hooks 6.178.0-alpha.0 → 6.178.0-alpha.2

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.
package/auth/hooks.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare type AuthStateMapper<S> = (state: AuthState) => S;
21
21
  */
22
22
  export declare function useAuth(): AuthState;
23
23
  export declare function useAuth<S>(stateMapper: AuthStateMapper<S>): S;
24
+ export declare function useAuthState(): AuthState;
24
25
  /**
25
26
  * ```jsx
26
27
  * export const MyFunctionComponent = () => {
package/auth/hooks.js CHANGED
@@ -27,6 +27,11 @@ export function useAuth(stateMapper = defaultMapper.state) {
27
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
28
  return stateMapper(useSnapshot(state));
29
29
  }
30
+ export function useAuthState() {
31
+ return useSnapshot(useStore().store.auth, {
32
+ sync: true
33
+ });
34
+ }
30
35
 
31
36
  /**
32
37
  * ```jsx
@@ -90,9 +95,7 @@ export const useAuthRoutes = () => useAuth(state => _extends({}, state.routes));
90
95
  export const useIsAuthenticated = () => {
91
96
  const {
92
97
  isAuthenticated
93
- } = useAuth(state => ({
94
- isAuthenticated: state.isAuthenticated
95
- }));
98
+ } = useSnapshot(useStore().store.auth);
96
99
  return isAuthenticated;
97
100
  };
98
101
 
package/auth/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2, } from './hooks';
1
+ export { useAuthState, useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2, } from './hooks';
2
2
  export * from './acceptInvitation';
3
3
  export * from './activateAccount';
4
4
  export * from './allAccounts';
package/auth/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2 } from './hooks';
1
+ export { useAuthState, useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2 } from './hooks';
2
2
  export * from './acceptInvitation';
3
3
  export * from './activateAccount';
4
4
  export * from './allAccounts';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.178.0-alpha.0
1
+ /** @license Frontegg v6.178.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useAuth = useAuth;
8
- exports.useOnRedirectTo = exports.useLoginWithRedirectV2 = exports.useLoginWithRedirect = exports.useIsAuthenticated = exports.useAuthUserOrNull = exports.useAuthUser = exports.useAuthRoutes = exports.useAuthActions = void 0;
8
+ exports.useAuthRoutes = exports.useAuthActions = void 0;
9
+ exports.useAuthState = useAuthState;
10
+ exports.useOnRedirectTo = exports.useLoginWithRedirectV2 = exports.useLoginWithRedirect = exports.useIsAuthenticated = exports.useAuthUserOrNull = exports.useAuthUser = void 0;
9
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
12
  var _react = require("react");
11
13
  var _restApi = require("@frontegg/rest-api");
@@ -35,6 +37,11 @@ function useAuth(stateMapper = defaultMapper.state) {
35
37
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
38
  return stateMapper((0, _react2.useSnapshot)(state));
37
39
  }
40
+ function useAuthState() {
41
+ return (0, _react2.useSnapshot)((0, _FronteggStoreContext.useStore)().store.auth, {
42
+ sync: true
43
+ });
44
+ }
38
45
 
39
46
  /**
40
47
  * ```jsx
@@ -103,9 +110,7 @@ exports.useAuthRoutes = useAuthRoutes;
103
110
  const useIsAuthenticated = () => {
104
111
  const {
105
112
  isAuthenticated
106
- } = useAuth(state => ({
107
- isAuthenticated: state.isAuthenticated
108
- }));
113
+ } = (0, _react2.useSnapshot)((0, _FronteggStoreContext.useStore)().store.auth);
109
114
  return isAuthenticated;
110
115
  };
111
116
 
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
+ useAuthState: true,
7
8
  useAuth: true,
8
9
  useAuthActions: true,
9
10
  useOnRedirectTo: true,
@@ -32,6 +33,12 @@ Object.defineProperty(exports, "useAuthRoutes", {
32
33
  return _hooks.useAuthRoutes;
33
34
  }
34
35
  });
36
+ Object.defineProperty(exports, "useAuthState", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _hooks.useAuthState;
40
+ }
41
+ });
35
42
  Object.defineProperty(exports, "useAuthUser", {
36
43
  enumerable: true,
37
44
  get: function () {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.178.0-alpha.0
1
+ /** @license Frontegg v6.178.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.178.0-alpha.0",
3
+ "version": "6.178.0-alpha.2",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
- "@frontegg/redux-store": "6.178.0-alpha.0",
10
- "@frontegg/types": "6.178.0-alpha.0",
9
+ "@frontegg/redux-store": "6.178.0-alpha.2",
10
+ "@frontegg/types": "6.178.0-alpha.2",
11
11
  "@types/react": "*",
12
12
  "get-value": "^3.0.1",
13
13
  "react-redux": "^7.x"