ant-motion icon indicating copy to clipboard operation
ant-motion copied to clipboard

react fc组件下使用 QueueAnim 标签 报警告

Open Yixeu opened this issue 4 years ago • 5 comments

警告:Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Check the render method of TweenOne.

代码如下: <QueueAnim className="team-info employee-tab" ref={ref}> <Menu data={data ? data.tranList : null} loadNewPage={(id: string | number) => { getDataByDepart(id); }} /> {data && data.longList && data.longList.deptList ? data.longList.deptList.map( (itemData: departType, index: number) => { return ( <Department data={itemData} key={"dept" + index} loadNewPage={(id: string | number) => { getDataByDepart(id); }} /> ); } ) : null} </QueueAnim>

Menu和Department同为fc组件,未使用ref

Yixeu avatar Apr 24 '20 09:04 Yixeu

image

Yixeu avatar Apr 24 '20 09:04 Yixeu

image

Yixeu avatar Apr 24 '20 09:04 Yixeu

tween-one 是需要 ref 来做 dom 动画的,然而 React.foreardRef 不能解决子组件为三方组件时的使用,所以这个报警暂时没法解决。

jljsj33 avatar Apr 26 '20 06:04 jljsj33

你好 这个问题现在解决了吗

kaixinkaixinmeifannao avatar Apr 19 '22 03:04 kaixinkaixinmeifannao

React.forwardRef 包住组件试试

SmileABC avatar Aug 04 '22 06:08 SmileABC