From f2a9a5fe0a7db73205ed46a1050f395c2f071f2f Mon Sep 17 00:00:00 2001 From: Hebilicious Date: Wed, 25 Sep 2024 15:04:07 +0700 Subject: [PATCH] fix: triggerRef in the update selected function --- packages/xstate-vue/src/useSelector.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/xstate-vue/src/useSelector.ts b/packages/xstate-vue/src/useSelector.ts index 2e76b61b27..80b0ec75e7 100644 --- a/packages/xstate-vue/src/useSelector.ts +++ b/packages/xstate-vue/src/useSelector.ts @@ -1,4 +1,4 @@ -import { Ref, isRef, shallowRef, watch } from 'vue'; +import { Ref, isRef, shallowRef, triggerRef, watch } from 'vue'; import { AnyActorRef } from 'xstate'; function defaultCompare(a: T, b: T) { @@ -27,7 +27,9 @@ export function useSelector< const updateSelectedIfChanged = (nextSelected: T) => { if (!compare(selected.value, nextSelected)) { selected.value = nextSelected; - } + } else { + triggerRef(selected) + } }; watch(