ant-design-vue/components/_util/hooks/_vueuse/useSupported.ts

14 lines
332 B
TypeScript

import { tryOnMounted } from './tryOnMounted';
import { shallowRef } from 'vue';
export function useSupported(callback: () => unknown, sync = false) {
const isSupported = shallowRef<boolean>();
const update = () => (isSupported.value = Boolean(callback()));
update();
tryOnMounted(update, sync);
return isSupported;
}