preact-arco-design
Version:
Arco Design React UI Library.
19 lines (16 loc) • 444 B
JavaScript
// 保存一个ref列表
import { useRef } from "preact/compat";
export default function useRefs(defaultValue) {
if (defaultValue === void 0) {
defaultValue = [];
}
var listRef = useRef(defaultValue);
var setListRef = function setListRef(element, index) {
if (index !== undefined) {
listRef.current[index] = element;
} else {
listRef.current.push(element);
}
};
return [listRef.current, setListRef];
}