From 4f2f626dc84f45bb18ded6dd9aad3b6f6a2190b1 Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Wed, 28 Apr 2021 22:22:21 -0400 Subject: [PATCH] Add changeset --- .changeset/cyan-dolphins-change.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .changeset/cyan-dolphins-change.md diff --git a/.changeset/cyan-dolphins-change.md b/.changeset/cyan-dolphins-change.md new file mode 100644 index 0000000000..101b0fd87a --- /dev/null +++ b/.changeset/cyan-dolphins-change.md @@ -0,0 +1,29 @@ +--- +'xstate': minor +--- + +Tags can now be added to state node configs under the `.tags` property: + +```js +const machine = createMachine({ + initial: 'green', + states: { + green: { + tags: 'go' // single tag + }, + yellow: { + tags: 'go' + }, + red: { + tags: ['stop', 'other'] // multiple tags + } + } +}); +``` + +You can query whether a state has a tag via `state.hasTag(tag)`: + +```js +const canGo = state.hasTag('go'); +// => `true` if in 'green' or 'red' state +```