@chakra-ui/react
Version:
Responsive and accessible React UI components built with React and Emotion
26 lines (23 loc) • 471 B
JavaScript
function assignRef(ref, value) {
if (ref == null) return;
if (typeof ref === "function") {
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);
});
};
}
exports.assignRef = assignRef;
exports.mergeRefs = mergeRefs;
;
;