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

Select组件,当导入 'react-hot-loader/patch'时就会报错 #3550

Closed
zhangchao828 opened this issue Oct 24, 2016 · 17 comments
Closed

Select组件,当导入 'react-hot-loader/patch'时就会报错 #3550

zhangchao828 opened this issue Oct 24, 2016 · 17 comments

Comments

@zhangchao828
Copy link

  • antd 版本:2.1.0
  • 操作系统及其版本:window
  • 浏览器及其版本:chrome
    当我使用react-hot-loader3的时候,入口文件中导入 'react-hot-loader/patch'
    import 'react-hot-loader/patch'
    所有引用Select组件的地方就会报这个错:
    Warning: the children of Select should be Select.Option or Select.OptGroup, instead of Option.
    我去掉'react-hot-loader/patch‘就好了不知道怎么回事,反复检查没发现原因
@Ben07
Copy link

Ben07 commented Nov 25, 2016

找到原因了吗?我也遇到这个情况,一堆warning。有点烦人

@smile21
Copy link

smile21 commented Nov 29, 2016

+1

@afc163
Copy link
Member

afc163 commented Nov 30, 2016

和 Table.Column 的判断是一样的?@yesmeck

@afc163 afc163 reopened this Nov 30, 2016
@yesmeck
Copy link
Member

yesmeck commented Nov 30, 2016

react-hot-loader 会用 react-proxy 改掉原来的组件对象,要想想怎么搞。

@yesmeck
Copy link
Member

yesmeck commented Nov 30, 2016

有人提了 gaearon/react-hot-loader#304

@yesmeck
Copy link
Member

yesmeck commented Nov 30, 2016

有 hack 的办法,不过感觉这是 react-hot-loader 的问题。

@yesmeck
Copy link
Member

yesmeck commented Nov 30, 2016

hack 的办法比较搓:

// 给 Option 自定义个 `__name`
Option.__name = 'rc-select-option'

后面要比较的地方用这个__name做比较。

@zation
Copy link
Contributor

zation commented Dec 11, 2016

为什么不用 displayName 呢?

@yesmeck
Copy link
Member

yesmeck commented Dec 11, 2016

displayName 太容易冲突了。

@zation
Copy link
Contributor

zation commented Dec 12, 2016

其实冲突的可能性很小,只有当谁用了 rc-select-option 并且还传给 Antd 的 Select 组件了才会出问题

@benjycui
Copy link
Contributor

displayName 不推荐 facebook/react#4915 (comment)

@benjycui
Copy link
Contributor

benjycui commented Dec 13, 2016

开发环境各工具之间难免有冲突。我不认为这个问题能够解决,而且不影响到生产环境,也还好。

一堆warning。有点烦人

这个可以像 antd 这样,限制每个 warning 只会显示一次。

@supnate
Copy link

supnate commented Jan 2, 2017

Any update on this? Though it's not good to ask so but this is a very critical issue. It's not just warnings for Select but it doesn't work at all for Tree (#4404). This issue prevents people from using antd with Webpack and RHL which is very popular for React development.

I understand it's more like an issue of RHL. But it's just how RHL works. I don't think it could be resolved by RHL itself. And, high order component concept is widely accepted for React so element.type seems not to be reliable for type detection even without RHL. As I see there is isTreeNode property for TreeNode component, this could be workaround for other scenarios.

@benjycui
Copy link
Contributor

benjycui commented Jan 3, 2017

As I see there is isTreeNode property for TreeNode component, this could be workaround for other scenarios.

It seems that there is no better way...

@yesmeck
Copy link
Member

yesmeck commented Jan 3, 2017

给 react-proxy 提了个 issue gaearon/react-proxy#68

@yesmeck
Copy link
Member

yesmeck commented Jan 19, 2017

Traced in #4655.

@yesmeck yesmeck closed this as completed Jan 19, 2017
@lock
Copy link

lock bot commented May 2, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants