From 9d49e3005ca677f8892e7af209e96d43b41e121c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 26 Jul 2023 21:04:01 +0200 Subject: [PATCH] fix(devtools): correctly load initial states --- packages/pinia/src/devtools/actions.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/pinia/src/devtools/actions.ts b/packages/pinia/src/devtools/actions.ts index f28d8a03..2ea9af03 100644 --- a/packages/pinia/src/devtools/actions.ts +++ b/packages/pinia/src/devtools/actions.ts @@ -122,8 +122,12 @@ export async function actionGlobalOpenStateFile(pinia: Pinia) { function loadStoresState(pinia: Pinia, state: Record) { for (const key in state) { const storeState = pinia.state.value[key] + // store is already instantiated, patch it if (storeState) { Object.assign(storeState, state[key]) + } else { + // store is not instantiated, set the initial state + pinia.state.value[key] = state[key] as any } } } -- 2.47.2