From cacd735961d818a70c9995472faeb01236ba7088 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 14 Sep 2020 12:46:49 +0100 Subject: [PATCH] fix: override client context store on create --- packages/client/src/state/store.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/src/state/store.js b/packages/client/src/state/store.js index 7895700cd0..6464589b03 100644 --- a/packages/client/src/state/store.js +++ b/packages/client/src/state/store.js @@ -11,6 +11,7 @@ const contextStoreKey = (dataProviderId, childIndex) => `${dataProviderId}${childIndex >= 0 ? ":" + childIndex : ""}` // creates a store for a datacontext (e.g. each item in a list component) +// overrides store if already exists const create = (data, dataProviderId, childIndex, parentContextStoreId) => { const key = contextStoreKey(dataProviderId, childIndex) const state = { data } @@ -22,14 +23,13 @@ const create = (data, dataProviderId, childIndex, parentContextStoreId) => { ? contextStores[parentContextStoreId].state : rootState - if (!contextStores[key]) { - contextStores[key] = { - store: writable(state), - subscriberCount: 0, - state, - parentContextStoreId, - } + contextStores[key] = { + store: writable(state), + subscriberCount: 0, + state, + parentContextStoreId, } + return key }