import { ref, watch, onMounted } from 'vue';

// export function useComponentHandler<T>(props: { data?: T }) {
//     const item = ref<T | undefined>(props.data);

export function useComponentHandler<T>(props: { data: T }) {
    const item = ref<T>(props.data);

    watch(() => props.data, (newData) => {
        item.value = newData;
    }, { immediate: true });

    return {
        item
    };
}
