Skip to content

Commit

Permalink
fix(useDraggable): SSR compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 25, 2021
1 parent e4873a0 commit 9f19c15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
shamefully-hoist: true
shamefully-hoist=true
8 changes: 6 additions & 2 deletions packages/core/useDraggable/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineComponent, h, reactive, ref, unref } from 'vue-demi'
import { useDraggable, UseDraggableOptions, useStorage } from '@vueuse/core'
import { isClient, useDraggable, UseDraggableOptions, useStorage } from '@vueuse/core'
import { RenderableComponent } from '../types'

export interface UseDraggableProps extends UseDraggableOptions, RenderableComponent {
Expand Down Expand Up @@ -32,7 +32,11 @@ export const UseDraggable = defineComponent<UseDraggableProps>({
? useStorage(
props.storageKey,
unref(props.initialValue) || { x: 0, y: 0 },
props.storageType === 'session' ? sessionStorage : localStorage,
isClient
? props.storageType === 'session'
? sessionStorage
: localStorage
: undefined,
)
: props.initialValue || { x: 0, y: 0 }

Expand Down

0 comments on commit 9f19c15

Please sign in to comment.