You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
418 B
19 lines
418 B
import * as React from 'react';
|
|
import { useRef } from 'react';
|
|
export default function useRefs() {
|
|
var cacheRefs = useRef(new Map());
|
|
|
|
function getRef(key) {
|
|
if (!cacheRefs.current.has(key)) {
|
|
cacheRefs.current.set(key, /*#__PURE__*/React.createRef());
|
|
}
|
|
|
|
return cacheRefs.current.get(key);
|
|
}
|
|
|
|
function removeRef(key) {
|
|
cacheRefs.current.delete(key);
|
|
}
|
|
|
|
return [getRef, removeRef];
|
|
} |