Skip to content

Commit 9f4c75d

Browse files
authored
refactor: use rc-util getNodeRef (#57)
* refactor: use rc-util getNodeRef * chore: back of script
1 parent 7efe95d commit 9f4c75d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"dependencies": {
4949
"@babel/runtime": "^7.11.1",
5050
"classnames": "^2.2.1",
51-
"rc-util": "^5.43.0"
51+
"rc-util": "^5.44.0"
5252
},
5353
"devDependencies": {
5454
"@rc-component/father-plugin": "^1.0.1",

src/CSSMotion.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */
22
import classNames from 'classnames';
33
import findDOMNode from 'rc-util/lib/Dom/findDOMNode';
4-
import { fillRef, supportRef } from 'rc-util/lib/ref';
4+
import { fillRef, getNodeRef, supportRef } from 'rc-util/lib/ref';
55
import * as React from 'react';
66
import { useRef } from 'react';
77
import { Context } from './context';
@@ -233,12 +233,15 @@ export function genCSSMotion(config: CSSMotionConfig) {
233233

234234
// Auto inject ref if child node not have `ref` props
235235
if (React.isValidElement(motionChildren) && supportRef(motionChildren)) {
236-
const { ref: originNodeRef } = motionChildren as any;
236+
const originNodeRef = getNodeRef(motionChildren);
237237

238238
if (!originNodeRef) {
239-
motionChildren = React.cloneElement<any>(motionChildren, {
240-
ref: setNodeRef,
241-
});
239+
motionChildren = React.cloneElement(
240+
motionChildren as React.ReactElement,
241+
{
242+
ref: setNodeRef,
243+
},
244+
);
242245
}
243246
}
244247

0 commit comments

Comments
 (0)