@xstate/react 2.0.1 → 3.0.0
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/CHANGELOG.md +25 -0
- package/dist/xstate-react-fsm.umd.min.js +41 -15
- package/dist/xstate-react.umd.min.js +34 -23
- package/es/fsm.d.ts +3 -19
- package/es/fsm.js +35 -26
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/types.d.ts +1 -16
- package/es/types.js +1 -5
- package/es/useActor.js +12 -31
- package/es/useInterpret.d.ts +2 -1
- package/es/useInterpret.js +32 -43
- package/es/useMachine.d.ts +2 -4
- package/es/useMachine.js +39 -48
- package/es/useSelector.js +11 -52
- package/lib/fsm.d.ts +3 -19
- package/lib/fsm.js +34 -25
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -3
- package/lib/types.d.ts +1 -16
- package/lib/types.js +0 -6
- package/lib/useActor.js +11 -30
- package/lib/useInterpret.d.ts +2 -1
- package/lib/useInterpret.js +32 -42
- package/lib/useMachine.d.ts +2 -4
- package/lib/useMachine.js +37 -48
- package/lib/useSelector.js +10 -51
- package/package.json +12 -11
- package/es/useReactEffectActions.d.ts +0 -3
- package/es/useReactEffectActions.js +0 -76
- package/lib/useReactEffectActions.d.ts +0 -3
- package/lib/useReactEffectActions.js +0 -80
package/lib/useMachine.js
CHANGED
|
@@ -15,70 +15,59 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
15
15
|
}
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.useMachine =
|
|
19
|
+
exports.useMachine = void 0;
|
|
29
20
|
var react_1 = require("react");
|
|
21
|
+
var with_selector_1 = require("use-sync-external-store/shim/with-selector");
|
|
30
22
|
var xstate_1 = require("xstate");
|
|
31
|
-
var types_1 = require("./types");
|
|
32
23
|
var useInterpret_1 = require("./useInterpret");
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
var args = [];
|
|
36
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
37
|
-
args[_i] = arguments[_i];
|
|
38
|
-
}
|
|
39
|
-
// don't execute; just return
|
|
40
|
-
return function () {
|
|
41
|
-
return exec.apply(void 0, __spreadArray([], __read(args), false));
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperties(effectExec, {
|
|
45
|
-
name: { value: "effect:".concat(exec.name) },
|
|
46
|
-
__effect: { value: tag }
|
|
47
|
-
});
|
|
48
|
-
return effectExec;
|
|
49
|
-
}
|
|
50
|
-
function asEffect(exec) {
|
|
51
|
-
return createReactActionFunction(exec, types_1.ReactEffectType.Effect);
|
|
24
|
+
function identity(a) {
|
|
25
|
+
return a;
|
|
52
26
|
}
|
|
53
|
-
exports.asEffect = asEffect;
|
|
54
|
-
function asLayoutEffect(exec) {
|
|
55
|
-
return createReactActionFunction(exec, types_1.ReactEffectType.LayoutEffect);
|
|
56
|
-
}
|
|
57
|
-
exports.asLayoutEffect = asLayoutEffect;
|
|
58
27
|
function useMachine(getMachine) {
|
|
59
28
|
var _a = [];
|
|
60
29
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
61
30
|
_a[_i - 1] = arguments[_i];
|
|
62
31
|
}
|
|
63
32
|
var _b = __read(_a, 1), _c = _b[0], options = _c === void 0 ? {} : _c;
|
|
64
|
-
|
|
33
|
+
// using `useIdleInterpreter` allows us to subscribe to the service *before* we start it
|
|
34
|
+
// so we don't miss any notifications
|
|
35
|
+
var service = (0, useInterpret_1.useIdleInterpreter)(getMachine, options);
|
|
36
|
+
var getSnapshot = (0, react_1.useCallback)(function () {
|
|
37
|
+
if (service.status === xstate_1.InterpreterStatus.NotStarted) {
|
|
38
|
+
return (options.state
|
|
39
|
+
? xstate_1.State.create(options.state)
|
|
40
|
+
: service.machine.initialState);
|
|
41
|
+
}
|
|
42
|
+
return service.state;
|
|
43
|
+
}, [service]);
|
|
44
|
+
var isEqual = (0, react_1.useCallback)(function (prevState, nextState) {
|
|
45
|
+
if (service.status === xstate_1.InterpreterStatus.NotStarted) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
65
48
|
// Only change the current state if:
|
|
66
49
|
// - the incoming state is the "live" initial state (since it might have new actors)
|
|
67
50
|
// - OR the incoming state actually changed.
|
|
68
51
|
//
|
|
69
52
|
// The "live" initial state will have .changed === undefined.
|
|
70
|
-
var initialStateChanged = nextState.changed === undefined &&
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
var initialStateChanged = nextState.changed === undefined &&
|
|
54
|
+
(Object.keys(nextState.children).length > 0 ||
|
|
55
|
+
typeof prevState.changed === 'boolean');
|
|
56
|
+
return !(nextState.changed || initialStateChanged);
|
|
57
|
+
}, [service]);
|
|
58
|
+
var subscribe = (0, react_1.useCallback)(function (handleStoreChange) {
|
|
59
|
+
var unsubscribe = service.subscribe(handleStoreChange).unsubscribe;
|
|
60
|
+
return unsubscribe;
|
|
61
|
+
}, [service]);
|
|
62
|
+
var storeSnapshot = (0, with_selector_1.useSyncExternalStoreWithSelector)(subscribe, getSnapshot, getSnapshot, identity, isEqual);
|
|
63
|
+
(0, react_1.useEffect)(function () {
|
|
64
|
+
var rehydratedState = options.state;
|
|
65
|
+
service.start(rehydratedState ? xstate_1.State.create(rehydratedState) : undefined);
|
|
66
|
+
return function () {
|
|
67
|
+
service.stop();
|
|
68
|
+
service.status = xstate_1.InterpreterStatus.NotStarted;
|
|
69
|
+
};
|
|
74
70
|
}, []);
|
|
75
|
-
|
|
76
|
-
var _d = __read((0, react_1.useState)(function () {
|
|
77
|
-
var initialState = service.machine.initialState;
|
|
78
|
-
return (options.state
|
|
79
|
-
? xstate_1.State.create(options.state)
|
|
80
|
-
: initialState);
|
|
81
|
-
}), 2), state = _d[0], setState = _d[1];
|
|
82
|
-
return [state, service.send, service];
|
|
71
|
+
return [storeSnapshot, service.send, service];
|
|
83
72
|
}
|
|
84
73
|
exports.useMachine = useMachine;
|
package/lib/useSelector.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSelector = void 0;
|
|
4
4
|
var react_1 = require("react");
|
|
5
|
-
var
|
|
6
|
-
var use_isomorphic_layout_effect_1 = require("use-isomorphic-layout-effect");
|
|
5
|
+
var with_selector_1 = require("use-sync-external-store/shim/with-selector");
|
|
7
6
|
var useActor_1 = require("./useActor");
|
|
8
7
|
var utils_1 = require("./utils");
|
|
9
8
|
function isService(actor) {
|
|
@@ -20,55 +19,15 @@ var defaultGetSnapshot = function (a) {
|
|
|
20
19
|
function useSelector(actor, selector, compare, getSnapshot) {
|
|
21
20
|
if (compare === void 0) { compare = defaultCompare; }
|
|
22
21
|
if (getSnapshot === void 0) { getSnapshot = defaultGetSnapshot; }
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var current = selector(snapshot);
|
|
27
|
-
var notifySubscriber;
|
|
28
|
-
return {
|
|
29
|
-
getSnapshot: function () { return snapshot; },
|
|
30
|
-
getCurrentValue: function () { return current; },
|
|
31
|
-
setCurrentValue: function (newCurrent) {
|
|
32
|
-
current = newCurrent;
|
|
33
|
-
notifySubscriber === null || notifySubscriber === void 0 ? void 0 : notifySubscriber();
|
|
34
|
-
},
|
|
35
|
-
subscribe: function (callback) {
|
|
36
|
-
notifySubscriber = callback;
|
|
37
|
-
var sub = actor.subscribe(function (emitted) {
|
|
38
|
-
snapshot = emitted;
|
|
39
|
-
var next = latestSelectorRef.current(emitted);
|
|
40
|
-
if (!compare(current, next)) {
|
|
41
|
-
current = next;
|
|
42
|
-
callback();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return function () {
|
|
46
|
-
sub.unsubscribe();
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
// intentionally omit `getSnapshot` and `compare`
|
|
51
|
-
// - `getSnapshot`: it is only supposed to read the "initial" snapshot of an actor
|
|
52
|
-
// - `compare`: is really supposed to be idempotent and the same throughout the lifetime of this hook (the same assumption is made in React Redux v7)
|
|
22
|
+
var subscribe = (0, react_1.useCallback)(function (handleStoreChange) {
|
|
23
|
+
var unsubscribe = actor.subscribe(handleStoreChange).unsubscribe;
|
|
24
|
+
return unsubscribe;
|
|
53
25
|
}, [actor]);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
currentSelected = selected;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
(0, use_isomorphic_layout_effect_1.default)(function () {
|
|
64
|
-
latestSelectorRef.current = selector;
|
|
65
|
-
// this condition should not be required, but setState bailouts are currently buggy: https://github.com/facebook/react/issues/22654
|
|
66
|
-
if (currentChanged) {
|
|
67
|
-
// required so we don't cause a rerender by setting state (this could create infinite rerendering loop with inline selectors)
|
|
68
|
-
// at the same time we need to update the value within the subscription so new emits can compare against what has been returned to the user as current value
|
|
69
|
-
subscription.setCurrentValue(currentSelected);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return currentSelected;
|
|
26
|
+
var boundGetSnapshot = (0, react_1.useCallback)(function () { return getSnapshot(actor); }, [
|
|
27
|
+
actor,
|
|
28
|
+
getSnapshot
|
|
29
|
+
]);
|
|
30
|
+
var selectedSnapshot = (0, with_selector_1.useSyncExternalStoreWithSelector)(subscribe, boundGetSnapshot, boundGetSnapshot, selector, compare);
|
|
31
|
+
return selectedSnapshot;
|
|
73
32
|
}
|
|
74
33
|
exports.useSelector = useSelector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstate/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "XState tools for React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"url": "https://github.com/statelyai/xstate/issues"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@xstate/fsm": "^
|
|
56
|
-
"react": "^16.8.0 || ^17.0.0",
|
|
57
|
-
"xstate": "^4.
|
|
55
|
+
"@xstate/fsm": "^2.0.0",
|
|
56
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
57
|
+
"xstate": "^4.31.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@xstate/fsm": {
|
|
@@ -66,23 +66,24 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"use-isomorphic-layout-effect": "^1.0.0",
|
|
69
|
-
"use-
|
|
69
|
+
"use-sync-external-store": "^1.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@rollup/plugin-commonjs": "^17.0.0",
|
|
73
73
|
"@rollup/plugin-node-resolve": "^11.0.1",
|
|
74
|
-
"@testing-library/react": "^
|
|
74
|
+
"@testing-library/react": "^13.0.0",
|
|
75
75
|
"@types/jsdom": "^12.2.3",
|
|
76
|
-
"@types/react": "^
|
|
77
|
-
"@types/react-dom": "^
|
|
76
|
+
"@types/react": "^17.0.43",
|
|
77
|
+
"@types/react-dom": "^17.0.14",
|
|
78
|
+
"@types/use-sync-external-store": "^0.0.3",
|
|
78
79
|
"@xstate/fsm": "*",
|
|
79
80
|
"jest": "^26.6.3",
|
|
80
81
|
"jsdom": "^14.0.0",
|
|
81
82
|
"jsdom-global": "^3.0.2",
|
|
82
83
|
"lerna-alias": "3.0.3-0",
|
|
83
|
-
"react": "^
|
|
84
|
-
"react-dom": "^
|
|
85
|
-
"rollup": "^2.
|
|
84
|
+
"react": "^18.0.0",
|
|
85
|
+
"react-dom": "^18.0.0",
|
|
86
|
+
"rollup": "^2.69.0",
|
|
86
87
|
"rollup-plugin-replace": "^2.2.0",
|
|
87
88
|
"rollup-plugin-terser": "^5.1.2",
|
|
88
89
|
"rollup-plugin-typescript2": "^0.30.0",
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import { useEffect, useRef } from 'react';
|
|
27
|
-
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
|
|
28
|
-
import { ReactEffectType } from './types';
|
|
29
|
-
import { partition } from './utils';
|
|
30
|
-
function executeEffect(action, state) {
|
|
31
|
-
var exec = action.exec;
|
|
32
|
-
var originalExec = exec(state.context, state._event.data, {
|
|
33
|
-
action: action,
|
|
34
|
-
state: state,
|
|
35
|
-
_event: state._event
|
|
36
|
-
});
|
|
37
|
-
originalExec();
|
|
38
|
-
}
|
|
39
|
-
export function useReactEffectActions(service) {
|
|
40
|
-
var effectActionsRef = useRef([]);
|
|
41
|
-
var layoutEffectActionsRef = useRef([]);
|
|
42
|
-
useIsomorphicLayoutEffect(function () {
|
|
43
|
-
var sub = service.subscribe(function (currentState) {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
if (currentState.actions.length) {
|
|
46
|
-
var reactEffectActions = currentState.actions.filter(function (action) {
|
|
47
|
-
return (typeof action.exec === 'function' &&
|
|
48
|
-
'__effect' in action.exec);
|
|
49
|
-
});
|
|
50
|
-
var _c = __read(partition(reactEffectActions, function (action) {
|
|
51
|
-
return action.exec.__effect === ReactEffectType.Effect;
|
|
52
|
-
}), 2), effectActions = _c[0], layoutEffectActions = _c[1];
|
|
53
|
-
(_a = effectActionsRef.current).push.apply(_a, __spreadArray([], __read(effectActions.map(function (effectAction) { return [effectAction, currentState]; })), false));
|
|
54
|
-
(_b = layoutEffectActionsRef.current).push.apply(_b, __spreadArray([], __read(layoutEffectActions.map(function (layoutEffectAction) { return [layoutEffectAction, currentState]; })), false));
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return function () {
|
|
58
|
-
sub.unsubscribe();
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
// this is somewhat weird - this should always be flushed within useLayoutEffect
|
|
62
|
-
// but we don't want to receive warnings about useLayoutEffect being used on the server
|
|
63
|
-
// so we have to use `useIsomorphicLayoutEffect` to silence those warnings
|
|
64
|
-
useIsomorphicLayoutEffect(function () {
|
|
65
|
-
while (layoutEffectActionsRef.current.length) {
|
|
66
|
-
var _a = __read(layoutEffectActionsRef.current.shift(), 2), layoutEffectAction = _a[0], effectState = _a[1];
|
|
67
|
-
executeEffect(layoutEffectAction, effectState);
|
|
68
|
-
}
|
|
69
|
-
}); // https://github.com/statelyai/xstate/pull/1202#discussion_r429677773
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
while (effectActionsRef.current.length) {
|
|
72
|
-
var _a = __read(effectActionsRef.current.shift(), 2), effectAction = _a[0], effectState = _a[1];
|
|
73
|
-
executeEffect(effectAction, effectState);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.useReactEffectActions = void 0;
|
|
29
|
-
var react_1 = require("react");
|
|
30
|
-
var use_isomorphic_layout_effect_1 = require("use-isomorphic-layout-effect");
|
|
31
|
-
var types_1 = require("./types");
|
|
32
|
-
var utils_1 = require("./utils");
|
|
33
|
-
function executeEffect(action, state) {
|
|
34
|
-
var exec = action.exec;
|
|
35
|
-
var originalExec = exec(state.context, state._event.data, {
|
|
36
|
-
action: action,
|
|
37
|
-
state: state,
|
|
38
|
-
_event: state._event
|
|
39
|
-
});
|
|
40
|
-
originalExec();
|
|
41
|
-
}
|
|
42
|
-
function useReactEffectActions(service) {
|
|
43
|
-
var effectActionsRef = (0, react_1.useRef)([]);
|
|
44
|
-
var layoutEffectActionsRef = (0, react_1.useRef)([]);
|
|
45
|
-
(0, use_isomorphic_layout_effect_1.default)(function () {
|
|
46
|
-
var sub = service.subscribe(function (currentState) {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
if (currentState.actions.length) {
|
|
49
|
-
var reactEffectActions = currentState.actions.filter(function (action) {
|
|
50
|
-
return (typeof action.exec === 'function' &&
|
|
51
|
-
'__effect' in action.exec);
|
|
52
|
-
});
|
|
53
|
-
var _c = __read((0, utils_1.partition)(reactEffectActions, function (action) {
|
|
54
|
-
return action.exec.__effect === types_1.ReactEffectType.Effect;
|
|
55
|
-
}), 2), effectActions = _c[0], layoutEffectActions = _c[1];
|
|
56
|
-
(_a = effectActionsRef.current).push.apply(_a, __spreadArray([], __read(effectActions.map(function (effectAction) { return [effectAction, currentState]; })), false));
|
|
57
|
-
(_b = layoutEffectActionsRef.current).push.apply(_b, __spreadArray([], __read(layoutEffectActions.map(function (layoutEffectAction) { return [layoutEffectAction, currentState]; })), false));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return function () {
|
|
61
|
-
sub.unsubscribe();
|
|
62
|
-
};
|
|
63
|
-
}, []);
|
|
64
|
-
// this is somewhat weird - this should always be flushed within useLayoutEffect
|
|
65
|
-
// but we don't want to receive warnings about useLayoutEffect being used on the server
|
|
66
|
-
// so we have to use `useIsomorphicLayoutEffect` to silence those warnings
|
|
67
|
-
(0, use_isomorphic_layout_effect_1.default)(function () {
|
|
68
|
-
while (layoutEffectActionsRef.current.length) {
|
|
69
|
-
var _a = __read(layoutEffectActionsRef.current.shift(), 2), layoutEffectAction = _a[0], effectState = _a[1];
|
|
70
|
-
executeEffect(layoutEffectAction, effectState);
|
|
71
|
-
}
|
|
72
|
-
}); // https://github.com/statelyai/xstate/pull/1202#discussion_r429677773
|
|
73
|
-
(0, react_1.useEffect)(function () {
|
|
74
|
-
while (effectActionsRef.current.length) {
|
|
75
|
-
var _a = __read(effectActionsRef.current.shift(), 2), effectAction = _a[0], effectState = _a[1];
|
|
76
|
-
executeEffect(effectAction, effectState);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
exports.useReactEffectActions = useReactEffectActions;
|