Accessing returned hook state via .current
experimentalIn Svelte, hooks do not trigger component re-renders in the same way React hooks do. To ensure you always access the most up-to-date state, all non-function properties returned from hooks (such as isDragging, isDropping, isDragSource, and isDropTarget) must be accessed using a .current getter.
This pattern applies to:
useDraggableuseDroppableuseSortable
<script>
import {useSortable} from '@dnd-kit-svelte/svelte/sortable';
const {ref, isDragging} = useSortable({id});
</script>
<div {@attach ref}>
{isDragging.current ? 'Dragging' : 'Not dragging'}
</div>