From: Eduardo San Martin Morote Date: Mon, 27 Sep 2021 22:55:22 +0000 (+0200) Subject: fix(ssr): always call setActivePinia X-Git-Tag: pinia@2.0.0-rc.10~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83d7d2f4cabedf9c65ba90f2e18882261c49f71f;p=thirdparty%2Fvuejs%2Fpinia.git fix(ssr): always call setActivePinia Fix #665 --- diff --git a/packages/pinia/src/createPinia.ts b/packages/pinia/src/createPinia.ts index 00dd6282..be52f602 100644 --- a/packages/pinia/src/createPinia.ts +++ b/packages/pinia/src/createPinia.ts @@ -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)) }