@xstate/react 4.0.2 → 4.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/README.md +0 -8
- package/dist/declarations/src/createActorContext.d.ts +3 -3
- package/dist/declarations/src/useActor.d.ts +2 -2
- package/dist/declarations/src/useActorRef.d.ts +3 -3
- package/dist/declarations/src/useMachine.d.ts +2 -6
- package/dist/xstate-react.cjs.js +7 -4
- package/dist/xstate-react.development.cjs.js +7 -4
- package/dist/xstate-react.development.esm.js +7 -4
- package/dist/xstate-react.esm.js +7 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,14 +13,6 @@ This package contains utilities for using [XState](https://github.com/statelyai/
|
|
|
13
13
|
npm i xstate @xstate/react
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
**Via CDN**
|
|
17
|
-
|
|
18
|
-
```html
|
|
19
|
-
<script src="https://unpkg.com/@xstate/react/dist/xstate-react.umd.min.js"></script>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
By using the global variable `XStateReact`
|
|
23
|
-
|
|
24
16
|
2. Import the `useMachine` hook:
|
|
25
17
|
|
|
26
18
|
```js
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare function createActorContext<TLogic extends AnyActorLogic>(actorLogic: TLogic,
|
|
2
|
+
import { Actor, ActorOptions, AnyActorLogic, SnapshotFrom } from 'xstate';
|
|
3
|
+
export declare function createActorContext<TLogic extends AnyActorLogic>(actorLogic: TLogic, actorOptions?: ActorOptions<TLogic>): {
|
|
4
4
|
useSelector: <T>(selector: (snapshot: SnapshotFrom<TLogic>) => T, compare?: (a: T, b: T) => boolean) => T;
|
|
5
|
-
useActorRef: () =>
|
|
5
|
+
useActorRef: () => Actor<TLogic>;
|
|
6
6
|
Provider: (props: {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
options?: ActorOptions<TLogic>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useActor<TLogic extends AnyActorLogic>(logic: TLogic, options?: ActorOptions<TLogic>): [SnapshotFrom<TLogic>,
|
|
1
|
+
import { Actor, ActorOptions, AnyActorLogic, SnapshotFrom } from 'xstate';
|
|
2
|
+
export declare function useActor<TLogic extends AnyActorLogic>(logic: TLogic, options?: ActorOptions<TLogic>): [SnapshotFrom<TLogic>, Actor<TLogic>['send'], Actor<TLogic>];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useIdleActorRef(logic:
|
|
3
|
-
export declare function useActorRef<TLogic extends AnyActorLogic>(machine: TLogic, options?: ActorOptions<TLogic>, observerOrListener?: Observer<SnapshotFrom<TLogic>> | ((value: SnapshotFrom<TLogic>) => void)):
|
|
1
|
+
import { Actor, ActorOptions, AnyActorLogic, Observer, SnapshotFrom } from 'xstate';
|
|
2
|
+
export declare function useIdleActorRef<TLogic extends AnyActorLogic>(logic: TLogic, options: Partial<ActorOptions<TLogic>>): Actor<TLogic>;
|
|
3
|
+
export declare function useActorRef<TLogic extends AnyActorLogic>(machine: TLogic, options?: ActorOptions<TLogic>, observerOrListener?: Observer<SnapshotFrom<TLogic>> | ((value: SnapshotFrom<TLogic>) => void)): Actor<TLogic>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Actor, ActorOptions, AnyStateMachine, StateFrom } from 'xstate';
|
|
2
2
|
/**
|
|
3
3
|
* @alias useActor
|
|
4
4
|
*/
|
|
5
|
-
export declare function useMachine<TMachine extends AnyStateMachine>(machine: TMachine, options?: ActorOptions<TMachine>): [
|
|
6
|
-
StateFrom<TMachine>,
|
|
7
|
-
ActorRefFrom<TMachine>['send'],
|
|
8
|
-
ActorRefFrom<TMachine>
|
|
9
|
-
];
|
|
5
|
+
export declare function useMachine<TMachine extends AnyStateMachine>(machine: TMachine, options?: ActorOptions<TMachine>): [StateFrom<TMachine>, Actor<TMachine>['send'], Actor<TMachine>];
|
package/dist/xstate-react.cjs.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var shim = require('use-sync-external-store/shim');
|
|
7
|
-
var xstate = require('xstate');
|
|
8
7
|
var useIsomorphicLayoutEffect = require('use-isomorphic-layout-effect');
|
|
8
|
+
var xstate = require('xstate');
|
|
9
9
|
var withSelector = require('use-sync-external-store/shim/with-selector');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -165,19 +165,22 @@ function shallowEqual(objA, objB) {
|
|
|
165
165
|
return true;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function createActorContext(actorLogic,
|
|
168
|
+
function createActorContext(actorLogic, actorOptions) {
|
|
169
169
|
const ReactContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
170
170
|
const OriginalProvider = ReactContext.Provider;
|
|
171
171
|
function Provider({
|
|
172
172
|
children,
|
|
173
173
|
logic: providedLogic = actorLogic,
|
|
174
174
|
machine,
|
|
175
|
-
options: providedOptions
|
|
175
|
+
options: providedOptions
|
|
176
176
|
}) {
|
|
177
177
|
if (machine) {
|
|
178
178
|
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
|
|
179
179
|
}
|
|
180
|
-
const actor = useActorRef(providedLogic,
|
|
180
|
+
const actor = useActorRef(providedLogic, {
|
|
181
|
+
...actorOptions,
|
|
182
|
+
...providedOptions
|
|
183
|
+
});
|
|
181
184
|
return /*#__PURE__*/React__namespace.createElement(OriginalProvider, {
|
|
182
185
|
value: actor,
|
|
183
186
|
children
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var shim = require('use-sync-external-store/shim');
|
|
7
|
-
var xstate = require('xstate');
|
|
8
7
|
var useIsomorphicLayoutEffect = require('use-isomorphic-layout-effect');
|
|
8
|
+
var xstate = require('xstate');
|
|
9
9
|
var withSelector = require('use-sync-external-store/shim/with-selector');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -168,19 +168,22 @@ function shallowEqual(objA, objB) {
|
|
|
168
168
|
return true;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
function createActorContext(actorLogic,
|
|
171
|
+
function createActorContext(actorLogic, actorOptions) {
|
|
172
172
|
const ReactContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
173
173
|
const OriginalProvider = ReactContext.Provider;
|
|
174
174
|
function Provider({
|
|
175
175
|
children,
|
|
176
176
|
logic: providedLogic = actorLogic,
|
|
177
177
|
machine,
|
|
178
|
-
options: providedOptions
|
|
178
|
+
options: providedOptions
|
|
179
179
|
}) {
|
|
180
180
|
if (machine) {
|
|
181
181
|
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
|
|
182
182
|
}
|
|
183
|
-
const actor = useActorRef(providedLogic,
|
|
183
|
+
const actor = useActorRef(providedLogic, {
|
|
184
|
+
...actorOptions,
|
|
185
|
+
...providedOptions
|
|
186
|
+
});
|
|
184
187
|
return /*#__PURE__*/React__namespace.createElement(OriginalProvider, {
|
|
185
188
|
value: actor,
|
|
186
189
|
children
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect, useState, useCallback } from 'react';
|
|
3
3
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
4
|
-
import { toObserver, createActor } from 'xstate';
|
|
5
4
|
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
|
|
5
|
+
import { toObserver, createActor } from 'xstate';
|
|
6
6
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
7
7
|
|
|
8
8
|
const forEachActor = (actorRef, callback) => {
|
|
@@ -142,19 +142,22 @@ function shallowEqual(objA, objB) {
|
|
|
142
142
|
return true;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
function createActorContext(actorLogic,
|
|
145
|
+
function createActorContext(actorLogic, actorOptions) {
|
|
146
146
|
const ReactContext = /*#__PURE__*/React.createContext(null);
|
|
147
147
|
const OriginalProvider = ReactContext.Provider;
|
|
148
148
|
function Provider({
|
|
149
149
|
children,
|
|
150
150
|
logic: providedLogic = actorLogic,
|
|
151
151
|
machine,
|
|
152
|
-
options: providedOptions
|
|
152
|
+
options: providedOptions
|
|
153
153
|
}) {
|
|
154
154
|
if (machine) {
|
|
155
155
|
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
|
|
156
156
|
}
|
|
157
|
-
const actor = useActorRef(providedLogic,
|
|
157
|
+
const actor = useActorRef(providedLogic, {
|
|
158
|
+
...actorOptions,
|
|
159
|
+
...providedOptions
|
|
160
|
+
});
|
|
158
161
|
return /*#__PURE__*/React.createElement(OriginalProvider, {
|
|
159
162
|
value: actor,
|
|
160
163
|
children
|
package/dist/xstate-react.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect, useState, useCallback } from 'react';
|
|
3
3
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
4
|
-
import { toObserver, createActor } from 'xstate';
|
|
5
4
|
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
|
|
5
|
+
import { toObserver, createActor } from 'xstate';
|
|
6
6
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
7
7
|
|
|
8
8
|
const forEachActor = (actorRef, callback) => {
|
|
@@ -139,19 +139,22 @@ function shallowEqual(objA, objB) {
|
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
function createActorContext(actorLogic,
|
|
142
|
+
function createActorContext(actorLogic, actorOptions) {
|
|
143
143
|
const ReactContext = /*#__PURE__*/React.createContext(null);
|
|
144
144
|
const OriginalProvider = ReactContext.Provider;
|
|
145
145
|
function Provider({
|
|
146
146
|
children,
|
|
147
147
|
logic: providedLogic = actorLogic,
|
|
148
148
|
machine,
|
|
149
|
-
options: providedOptions
|
|
149
|
+
options: providedOptions
|
|
150
150
|
}) {
|
|
151
151
|
if (machine) {
|
|
152
152
|
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
|
|
153
153
|
}
|
|
154
|
-
const actor = useActorRef(providedLogic,
|
|
154
|
+
const actor = useActorRef(providedLogic, {
|
|
155
|
+
...actorOptions,
|
|
156
|
+
...providedOptions
|
|
157
|
+
});
|
|
155
158
|
return /*#__PURE__*/React.createElement(OriginalProvider, {
|
|
156
159
|
value: actor,
|
|
157
160
|
children
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstate/react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "XState tools for React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
58
|
-
"xstate": "^5.
|
|
58
|
+
"xstate": "^5.5.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"xstate": {
|
|
@@ -76,6 +76,6 @@
|
|
|
76
76
|
"jsdom-global": "^3.0.2",
|
|
77
77
|
"react": "^18.0.0",
|
|
78
78
|
"react-dom": "^18.0.0",
|
|
79
|
-
"xstate": "5.
|
|
79
|
+
"xstate": "5.5.2"
|
|
80
80
|
}
|
|
81
81
|
}
|