@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.
- package/lib/routing/providers.js +3 -2
- package/lib/xstateTree.js +6 -3
- package/package.json +1 -1
package/lib/routing/providers.js
CHANGED
|
@@ -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 (
|
|
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
|
|
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
|
-
}, [
|
|
196
|
+
}, []);
|
|
194
197
|
if (!interpreter.initialized) {
|
|
195
198
|
setTimeout(() => forceRender(!forceRenderValue), 0);
|
|
196
199
|
return null;
|