Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Yixeu opened this issue Apr 24, 2020 · 5 comments
Open

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

Yixeu opened this issue Apr 24, 2020 · 5 comments

Comments

@Yixeu
Copy link

Yixeu commented Apr 24, 2020

警告: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
Copy link
Author

Yixeu commented Apr 24, 2020

image

@Yixeu
Copy link
Author

Yixeu commented Apr 24, 2020

image

@jljsj33
Copy link
Member

jljsj33 commented Apr 26, 2020

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

@kaixinkaixinmeifannao
Copy link

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

@SmileABC
Copy link

SmileABC commented Aug 4, 2022

React.forwardRef 包住组件试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants