Files
wdi-dashboard/node_modules/@chakra-ui/react-utils/dist/chunk-A3EAUGIL.mjs
2024-08-16 15:06:52 +05:30

26 lines
458 B
JavaScript

// src/refs.ts
import { isFunction } from "@chakra-ui/utils";
function assignRef(ref, value) {
if (ref == null)
return;
if (isFunction(ref)) {
ref(value);
return;
}
try {
ref.current = value;
} catch (error) {
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
}
}
function mergeRefs(...refs) {
return (node) => {
refs.forEach((ref) => assignRef(ref, node));
};
}
export {
assignRef,
mergeRefs
};