Skip to content

Commit f70d5ea

Browse files
committed
refactor(ssr): shorter useIsSSR
1 parent 2725596 commit f70d5ea

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/shared.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,11 @@ const ssrContextKey = Symbol.for('v-scx')
277277
*/
278278
export function useIsSSR(): boolean {
279279
const instance = getCurrentInstance()
280-
if (isVue2) {
281-
return (
282-
!!instance &&
280+
return !!(isVue2
281+
? instance &&
283282
// @ts-expect-error: Vue 2 only API
284-
instance.proxy.$isServer
285-
)
286-
}
287-
return !!inject(ssrContextKey, 0)
283+
(instance.proxy.$isServer as boolean)
284+
: inject(ssrContextKey, 0))
288285
}
289286

290287
/**

0 commit comments

Comments
 (0)