Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Vue3: Can I return a component in a composition javascript function?

I've got the following composable function:

import { DeleteFunction, DjangoModel, JsonModel, Reffed } from "@/types/shared";
import { ref, Ref, unref } from "vue";

export default function useDeleteItem<
  Fn extends (...args: any[]) => Promise<void>, // eslint-disable-line
>(
  deleteItemFunc: Fn,
  items: Ref<DjangoModel[]>,
  ...params: Reffed<Parameters<Fn>>
) {
  const deleteModalOpen = ref(false);

  const deleteRequest: DeleteFunction = (data: JsonModel) => {
    return deleteItemFunc(data, ...params.map(unref)).then(() => {
      deleteModalOpen.value = false;
      items.value = items.value.filter((item) => item.id !== data.id);
    });
  };

  return {
    deleteRequest,
    deleteModalOpen,
  };
}

Would it be possible to also return the Modal Component from my file ModalFree.vue? I can't figure out if that is possible.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!