-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42ead53
commit a7da145
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
'xstate': patch | ||
--- | ||
|
||
The "Attempted to spawn an Actor [...] outside of a service. This will have no effect." warnings are now silenced for "lazily spawned" actors, which are actors that aren't immediately active until the function that creates them are called: | ||
|
||
```js | ||
// ⚠️ "active" actor - will warn | ||
spawn(somePromise); | ||
|
||
// 🕐 "lazy" actor - won't warn | ||
spawn(() => somePromise); | ||
|
||
// 🕐 machines are also "lazy" - won't warn | ||
spawn(someMachine); | ||
``` | ||
|
||
It is recommended that all `spawn(...)`-ed actors are lazy, to avoid accidentally initializing them e.g., when reading `machine.initialState` or calculating otherwise pure transitions. In V5, this will be enforced. |