]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(devtools): state formatting
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Jul 2022 09:33:54 +0000 (11:33 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Jul 2022 09:33:54 +0000 (11:33 +0200)
Fix #1358

packages/pinia/src/devtools/plugin.ts

index 04e4abdc5576561c73021e1cbe9fb0b9f3887b11..97b08c463cb95fe1adf7c4400b0a4863c127624b 100644 (file)
@@ -134,7 +134,7 @@ export function registerPiniaDevtools(app: DevtoolsApp, pinia: Pinia) {
               value: store._isOptionsAPI
                 ? {
                     _custom: {
-                      value: store.$state,
+                      value: toRaw(store.$state),
                       actions: [
                         {
                           icon: 'restore',
@@ -144,7 +144,11 @@ export function registerPiniaDevtools(app: DevtoolsApp, pinia: Pinia) {
                       ],
                     },
                   }
-                : store.$state,
+                : // NOTE: workaround to unwrap transferred refs
+                  Object.keys(store.$state).reduce((state, key) => {
+                    state[key] = store.$state[key]
+                    return state
+                  }, {} as StateTree),
             })
 
             if (store._getters && store._getters.length) {