From bf9ce37b64e025ecccd8ff7627fcb3602e2ab32a Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:33:54 +0100 Subject: [PATCH] update(store): only inject if in current instance Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com> --- src/composables/useStore.ts | 8 +++++--- src/container/VueFlow/VueFlow.vue | 18 +++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/composables/useStore.ts b/src/composables/useStore.ts index b535378c..59774697 100644 --- a/src/composables/useStore.ts +++ b/src/composables/useStore.ts @@ -1,3 +1,4 @@ +import { getCurrentInstance } from 'vue' import { FlowExportObject, FlowOptions, FlowState, FlowStore } from '~/types' import { useNewStore } from '~/store' import { StoreSymbol } from '~/context' @@ -36,11 +37,12 @@ export const createStore = (options?: FlowOptions) => { } export default (options?: FlowOptions): FlowStore => { - let store = options?.id ? createStore(options) : inject(StoreSymbol, undefined) - if (!store) { + const currentInstance = getCurrentInstance() + let store = currentInstance ? inject(StoreSymbol, undefined) : false + if (!store || (store && options?.id && options.id !== store.id?.value)) { store = createStore(options) } - provide(StoreSymbol, store) + if (currentInstance) provide(StoreSymbol, store) return reactive(store) } diff --git a/src/container/VueFlow/VueFlow.vue b/src/container/VueFlow/VueFlow.vue index 28808cb6..26f955ca 100644 --- a/src/container/VueFlow/VueFlow.vue +++ b/src/container/VueFlow/VueFlow.vue @@ -146,10 +146,14 @@ const transitionName = computed(() => { return name }) - + - + @@ -230,11 +234,7 @@ const transitionName = computed(() => { - + @@ -244,8 +244,8 @@ const transitionName = computed(() => { - - + +