diff --git a/package.json b/package.json index 62e133e..8112b03 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", - "rc-util": "^5.43.0" + "rc-util": "^5.44.0" }, "devDependencies": { "@rc-component/father-plugin": "^1.0.1", diff --git a/src/CSSMotion.tsx b/src/CSSMotion.tsx index bff0e6c..5660e20 100644 --- a/src/CSSMotion.tsx +++ b/src/CSSMotion.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */ import classNames from 'classnames'; import findDOMNode from 'rc-util/lib/Dom/findDOMNode'; -import { fillRef, supportRef } from 'rc-util/lib/ref'; +import { fillRef, getNodeRef, supportRef } from 'rc-util/lib/ref'; import * as React from 'react'; import { useRef } from 'react'; import { Context } from './context'; @@ -233,12 +233,15 @@ export function genCSSMotion(config: CSSMotionConfig) { // Auto inject ref if child node not have `ref` props if (React.isValidElement(motionChildren) && supportRef(motionChildren)) { - const { ref: originNodeRef } = motionChildren as any; + const originNodeRef = getNodeRef(motionChildren); if (!originNodeRef) { - motionChildren = React.cloneElement(motionChildren, { - ref: setNodeRef, - }); + motionChildren = React.cloneElement( + motionChildren as React.ReactElement, + { + ref: setNodeRef, + }, + ); } }