From 5b0c92cc592fbea910cc5b78f50d87dfb0162b10 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 19 May 2022 14:31:57 +0200 Subject: [PATCH] docs: skipHydrate api --- packages/pinia/src/store.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/pinia/src/store.ts b/packages/pinia/src/store.ts index 8985c537b0..9987608a21 100644 --- a/packages/pinia/src/store.ts +++ b/packages/pinia/src/store.ts @@ -84,6 +84,13 @@ const skipHydrateSymbol = __DEV__ : /* istanbul ignore next */ Symbol() const skipHydrateMap = /*#__PURE__*/ new WeakMap() +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ export function skipHydrate(obj: T): T { return isVue2 ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...