Skip to content

Commit 2776b92

Browse files
committed
refactor: use rc-util getNodeRef
1 parent 7efe95d commit 2776b92

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"lint": "eslint src/ --ext .tsx,.ts",
3434
"now-build": "npm run docs:build",
3535
"prepare": "husky install",
36-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
36+
"prepublishOnly": "npm run compile",
3737
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
3838
"postpublish": "npm run docs:build && npm run docs:deploy",
3939
"start": "dumi dev",
@@ -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)