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

Drawer组件3.20.4之后版本children的Ref首次不能正常获取 #17886

Closed
1 task
TivonJJ opened this issue Jul 25, 2019 · 6 comments
Closed
1 task

Drawer组件3.20.4之后版本children的Ref首次不能正常获取 #17886

TivonJJ opened this issue Jul 25, 2019 · 6 comments
Assignees
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive

Comments

@TivonJJ
Copy link

TivonJJ commented Jul 25, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://codepen.io/tivonjj/pen/NQrMrX?editors=0011

Steps to reproduce

this.setState({
visible: true,
},()=>{
console.log(this.formRef)
});
第一次显示,在setState回调内ref是undefined,children并未初始化,但是3.20.3及之前版本一直正常,升级到3.20.4及之后版本都存在此问题

What is expected?

第一次显示可以获取children的Ref

What is actually happening?

第一次显示无法获取children的Ref

Environment Info
antd 3.20.4
React 16.4.1
System Window 10
Browser chrome
@jljsj33
Copy link
Member

jljsj33 commented Jul 29, 2019

额,ref 第一次进入时是 null,,可以先用 setTimeout 解决, 等 drawer didmount 后再做输出,,或者你用 forceRender。。。。

this.setState({
  visible: true,
}, () => {
  setTimeout(() => {
    console.log(this.formRef)
  })
});

@TivonJJ
Copy link
Author

TivonJJ commented Jul 29, 2019

额,ref 第一次进入时是 null,,可以先用 setTimeout 解决, 等 drawer didmount 后再做输出,,或者你用 forceRender。。。。

this.setState({
  visible: true,
}, () => {
  setTimeout(() => {
    console.log(this.formRef)
  })
});

以前项目改动量大,暂时降低版本解决了,但是在setState回调里面还Timeout觉得有点奇怪

@jljsj33
Copy link
Member

jljsj33 commented Aug 1, 2019

yesmeck added a commit to react-component/util that referenced this issue Aug 2, 2019
@yesmeck yesmeck reopened this Aug 2, 2019
@afc163
Copy link
Member

afc163 commented Mar 13, 2020

#21543 (comment) 的描述,Drawer 的 forceRender 实现貌似有问题。

@afc163 afc163 assigned zombieJ and unassigned afc163 Mar 13, 2020
@afc163 afc163 added 🐛 Bug Ant Design Team had proved that this is a bug. and removed Inactive labels Mar 13, 2020
@phifa
Copy link

phifa commented Apr 14, 2020

so drawer does not take forceRender. any other way?

@afc163
Copy link
Member

afc163 commented Jul 21, 2021

It had been fixed in antd 4.x, check https://codepen.io/afc163/pen/PomKdmJ?editors=0010

@afc163 afc163 closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive
Projects
None yet
Development

No branches or pull requests

7 participants