]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(ssr): always call setActivePinia
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 27 Sep 2021 22:55:22 +0000 (00:55 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 27 Sep 2021 22:55:34 +0000 (00:55 +0200)
Fix #665

packages/pinia/src/createPinia.ts

index 00dd62820b7da4f2657c281578a17bb47c04ae82..be52f602dac013d9b678b5535cad2bb8a2dea29b 100644 (file)
@@ -24,18 +24,16 @@ export function createPinia(): Pinia {
 
   const pinia: Pinia = markRaw({
     install(app: App) {
+      // this allows calling useStore() outside of a component setup after
+      // installing pinia's plugin
+      setActivePinia(pinia)
       if (!isVue2) {
         pinia._a = app
         app.provide(piniaSymbol, pinia)
         app.config.globalProperties.$pinia = pinia
-        if (IS_CLIENT) {
-          // this allows calling useStore() outside of a component setup after
-          // installing pinia's plugin
-          setActivePinia(pinia)
-          /* istanbul ignore else */
-          if (__DEV__) {
-            registerPiniaDevtools(app, pinia)
-          }
+        /* istanbul ignore else */
+        if (IS_CLIENT && __DEV__) {
+          registerPiniaDevtools(app, pinia)
         }
         toBeInstalled.forEach((plugin) => _p.push(plugin))
       }