Skip to content

Commit

Permalink
Allow to disable removing the predictable action arguments warning by…
Browse files Browse the repository at this point in the history
… setting the flag to false (#3666)

* Remove predictableActionArguments warning

* Add changeset

* Remove warning

* Modify warning

* Update .changeset/silver-mayflies-speak.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
davidkpiano and Andarist committed Nov 5, 2022
1 parent 6dc3bc0 commit 5e0808e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silver-mayflies-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

The warning for the `predictableActionArguments` setting has been improved to only warn if it is absent. You can disable the warning by setting `predictableActionArguments: false`. It's still recommended to set it to `true` though.
3 changes: 2 additions & 1 deletion packages/core/src/Machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ export function createMachine<
TServiceMap,
TTypesMeta
> {
if (!IS_PRODUCTION && !config.predictableActionArguments && !warned) {
if (!IS_PRODUCTION && !('predictableActionArguments' in config) && !warned) {
warned = true;
console.warn(
'It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html'
);
}

return new StateNode(config, options as any) as any;
}

0 comments on commit 5e0808e

Please sign in to comment.