@koordinates/xstate-tree 2.0.2 → 2.0.3

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.
@@ -8,11 +8,12 @@ function useRoutingContext() {
8
8
  return context;
9
9
  }
10
10
  export function useActiveRouteEvents() {
11
+ var _a;
11
12
  try {
12
13
  const context = useRoutingContext();
13
- return context.activeRouteEvents;
14
+ return (_a = context.activeRouteEvents) === null || _a === void 0 ? void 0 : _a.current;
14
15
  }
15
- catch (_a) {
16
+ catch (_b) {
16
17
  return undefined;
17
18
  }
18
19
  }
package/lib/xstateTree.js CHANGED
@@ -149,8 +149,11 @@ export function buildRootComponent(machine, routing) {
149
149
  }
150
150
  const RootComponent = function XstateTreeRootComponent() {
151
151
  const [_, __, interpreter] = useMachine(machine, { devTools: true });
152
- const [activeRouteEvents, setActiveRouteEvents] = useState(undefined);
152
+ const activeRouteEventsRef = useRef([]);
153
153
  const [forceRenderValue, forceRender] = useState(false);
154
+ const setActiveRouteEvents = (events) => {
155
+ activeRouteEventsRef.current = events;
156
+ };
154
157
  useEffect(() => {
155
158
  function handler(event) {
156
159
  recursivelySend(interpreter, event);
@@ -188,9 +191,9 @@ export function buildRootComponent(machine, routing) {
188
191
  return null;
189
192
  }
190
193
  return {
191
- activeRouteEvents,
194
+ activeRouteEvents: activeRouteEventsRef,
192
195
  };
193
- }, [activeRouteEvents]);
196
+ }, []);
194
197
  if (!interpreter.initialized) {
195
198
  setTimeout(() => forceRender(!forceRenderValue), 0);
196
199
  return null;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koordinates/xstate-tree",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/xstate-tree.d.ts",
5
- "version": "2.0.2",
5
+ "version": "2.0.3",
6
6
  "dependencies": {
7
7
  "@xstate/react": "3.0.0",
8
8
  "fast-memoize": "2.5.2",