From d024950dda6973e545c13c73af6018d49933b4d8 Mon Sep 17 00:00:00 2001 From: xingyu Date: Fri, 11 Aug 2023 20:18:23 +0800 Subject: [PATCH] fix: toRefs --- src/hooks/core/useRefs.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/hooks/core/useRefs.ts b/src/hooks/core/useRefs.ts index 79c280f9..ec380993 100644 --- a/src/hooks/core/useRefs.ts +++ b/src/hooks/core/useRefs.ts @@ -1,20 +1,16 @@ import type { Ref } from 'vue' import { onBeforeUpdate, ref } from 'vue' -function useRefs(): { refs: Ref; setRefs: (index: number) => (el: T) => void } { - const refs = ref([]) as Ref +export function useRefs(): [Ref, (index: number) => (el: HTMLElement) => void] { + const refs = ref([]) as Ref onBeforeUpdate(() => { refs.value = [] }) - const setRefs = (index: number) => (el: T) => { + const setRefs = (index: number) => (el: HTMLElement) => { refs.value[index] = el } - return { - refs, - setRefs, - } + return [refs, setRefs] } -export { useRefs }