useRefs.js 274 B

123456789101112
  1. import { onBeforeUpdate, ref } from 'vue';
  2. const useRefs = () => {
  3. const refs = ref(new Map());
  4. const setRef = key => el => {
  5. refs.value.set(key, el);
  6. };
  7. onBeforeUpdate(() => {
  8. refs.value = new Map();
  9. });
  10. return [setRef, refs];
  11. };
  12. export default useRefs;