]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(warn): avoid toRefs warning for Vue 2
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 3 Oct 2021 09:48:05 +0000 (11:48 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 3 Oct 2021 09:48:14 +0000 (11:48 +0200)
Fix #648

If this PR https://github.com/vuejs/composition-api/pull/821 gets fixed, this commit can be reverted

packages/pinia/src/store.ts

index c7467a6e351ecd8b34a85e79b2c627289054666b..96b8465f07333bc6c69708d442c671ffcc827fa4 100644 (file)
@@ -221,7 +221,9 @@ function createSetupStore<
   let debuggerEvents: DebuggerEvent[] | DebuggerEvent
   const initialState = pinia.state.value[$id] as UnwrapRef<S> | undefined
 
-  if (!initialState && (!__DEV__ || !hot)) {
+  // avoid setting the state for option stores are it is set
+  // by the setup
+  if (!buildState && !initialState && (!__DEV__ || !hot)) {
     if (isVue2) {
       set(pinia.state.value, $id, {})
     } else {