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

为什么 DialogWrap unmount 的时候还要再去检查 visiable 并 render 一次 Dialog? #18

Closed
yesmeck opened this issue Mar 14, 2016 · 6 comments

Comments

@yesmeck
Copy link
Member

yesmeck commented Mar 14, 2016

这里 https://github.com/react-component/dialog/blob/master/src%2FDialogWrap.jsx#L53-L58

我想自己去 unmount DialogWrap(不改变 visible),但是发现这里如果visible: true的会再次 render Dialog,这时如果在DialogWrap的 children 里有用 ref的话 react 就会报错。

例子:http://codepen.io/yesmeck/pen/ONRvrz?editors=0010

打开 modal 后点击关闭就会报错。

@yesmeck yesmeck changed the title 为什么 componentWillUnmount 的时候还要去检查 visiable 再 render 一次 Dialog 为什么 DialogWrap unmount 的时候还要去检查 visiable 再 render 一次 Dialog Mar 14, 2016
@yesmeck yesmeck changed the title 为什么 DialogWrap unmount 的时候还要去检查 visiable 再 render 一次 Dialog 为什么 DialogWrap unmount 的时候还要再去检查 visiable 并 render 一次 Dialog Mar 14, 2016
@yesmeck yesmeck changed the title 为什么 DialogWrap unmount 的时候还要再去检查 visiable 并 render 一次 Dialog 为什么 DialogWrap unmount 的时候还要再去检查 visiable 并 render 一次 Dialog? Mar 14, 2016
@yesmeck
Copy link
Member Author

yesmeck commented Mar 14, 2016

同样的问题 ant-design/ant-design#935

@yesmeck
Copy link
Member Author

yesmeck commented Mar 15, 2016

我知道了,是为了显示关闭动画吧。但是这样的话在使用react-router的情况下,在Dialog显示的时候改变路由,也会出错吧。

@yiminghe
Copy link
Member

facebook/react#6095

用 ref function

@yesmeck
Copy link
Member Author

yesmeck commented Mar 17, 2016

但是在用react-router的情况下就没办法用ref手动 unmount 了吧。

@yiminghe
Copy link
Member

试下 这种,没问题的

ref={(c) => {this.c=c}}

@yesmeck
Copy link
Member Author

yesmeck commented Mar 17, 2016

嗯,这样没问题了

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

2 participants