Files
video-gen/video-gen-admin/node_modules/antd/lib/form/hooks/useItemRef.js
T
2026-05-25 17:08:18 +08:00

29 lines
1.0 KiB
JavaScript

"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _ref = require("@rc-component/util/lib/ref");
var _context = require("../context");
const useItemRef = () => {
const {
itemRef
} = React.useContext(_context.FormContext);
const cacheRef = React.useRef({});
function getRef(name, children) {
// Outer caller already check the `supportRef`
const childrenRef = children && typeof children === 'object' && (0, _ref.getNodeRef)(children);
const nameStr = name.join('_');
if (cacheRef.current.name !== nameStr || cacheRef.current.originRef !== childrenRef) {
cacheRef.current.name = nameStr;
cacheRef.current.originRef = childrenRef;
cacheRef.current.ref = (0, _ref.composeRef)(itemRef(name), childrenRef);
}
return cacheRef.current.ref;
}
return getRef;
};
var _default = exports.default = useItemRef;