@clicktap/state 0.11.1 → 0.11.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/index.esm.js CHANGED
@@ -466,18 +466,18 @@ var authMachine = setup({
466
466
  }
467
467
  });
468
468
 
469
- var AuthContext = /*#__PURE__*/createContext(undefined);
469
+ var AuthContext = /*#__PURE__*/createContext(createActor(authMachine));
470
470
  var useAuth = function useAuth() {
471
- var actor = useContext(AuthContext);
472
- if (!actor) return {
473
- authActor: undefined,
471
+ var authActor = useContext(AuthContext);
472
+ if (!authActor) return {
473
+ authActor: authActor,
474
474
  isLoggedIn: false
475
475
  };
476
- var _useState = useState(actor.getSnapshot().value === 'loggedIn'),
476
+ var _useState = useState(authActor.getSnapshot().value === 'loggedIn'),
477
477
  isLoggedIn = _useState[0],
478
478
  setIsLoggedIn = _useState[1];
479
479
  useEffect(function () {
480
- var subscription = actor.subscribe(function (observer) {
480
+ var subscription = authActor.subscribe(function (observer) {
481
481
  if (observer.value === 'loggedIn' || observer.value === 'loggedOut') {
482
482
  setIsLoggedIn(observer.value === 'loggedIn');
483
483
  }
@@ -485,9 +485,9 @@ var useAuth = function useAuth() {
485
485
  return function () {
486
486
  subscription.unsubscribe();
487
487
  };
488
- }, [actor]);
488
+ }, [authActor]);
489
489
  return {
490
- authActor: actor,
490
+ authActor: authActor,
491
491
  isLoggedIn: isLoggedIn
492
492
  };
493
493
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clicktap/state",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "private": false,
5
5
  "author": "Clicktap",
6
6
  "description": "A state management library for Clicktap reference frontend.",
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { Actor, InspectionEvent, Observer } from 'xstate';
3
3
  import { authMachine } from './auth';
4
4
  export interface AuthContextType {
5
- authActor: Actor<typeof authMachine> | undefined;
5
+ authActor: Actor<typeof authMachine>;
6
6
  isLoggedIn: boolean;
7
7
  }
8
8
  export declare const AuthContext: import("react").Context<Actor<import("xstate").StateMachine<import("./auth").AuthMachineContext, import("./auth").RefreshTokenEvent | import("./auth").LoginEvent | import("./auth").LogoutEvent | import("./auth").ClearErrorsEvent | import("xstate").DoneActorEvent<import("./auth").AuthenticateSuccessEvent> | import("xstate").DoneActorEvent<import("./auth").RefreshTokenSuccessEvent>, {
@@ -139,7 +139,7 @@ export declare const AuthContext: import("react").Context<Actor<import("xstate")
139
139
  }, {
140
140
  type: string;
141
141
  params: import("xstate").NonReducibleUnknown;
142
- }, string, string>>> | undefined>;
142
+ }, string, string>>>>;
143
143
  export declare const useAuth: () => AuthContextType;
144
144
  type AuthOptions = {
145
145
  inspect: Observer<InspectionEvent> | undefined;