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

Dropdown.Item 封装成组件放在 Dropdown 下面点击无反应 #6426

Closed
liqiuqiui opened this issue Nov 9, 2023 · 4 comments
Closed
Labels

Comments

@liqiuqiui
Copy link
Contributor

Version of antd-mobile

5.33.0

Operating system and its version

Android, Others

Browser and its version

any

Sandbox to reproduce

https://codesandbox.io/s/wizardly-clarke-g9yvk8?file=/src/App.tsx

What happened?

问题:

Dropdown.Item必须直接放在 Dropdown下作为 children 才能正常点击弹出 popup。一旦Dropdown.Item被封装成组件,渲染出来的item 点击无任何反应。影响了组件封装的灵活性。
问题复现 demo

期望的正确行为:

Dropdown.Item 被封装成组件放在 Dropdown 里也可以正常使用

Relevant log output

No response

@liqiuqiui liqiuqiui added the bug label Nov 9, 2023
@zombieJ
Copy link
Member

zombieJ commented Nov 9, 2023

内部是通过子组件的 props 来收集信息的,HOC 后你也需要把属性写到最外层才行。

jsx 结构本身是语法糖,是不支持 HOC 的。

@1587315093
Copy link
Contributor

Dropdown.Item 的 props,是由Dropdown传下去的

套了一层相当于把它props隔离掉了,onClick自然也没设置到 Item 上

image

@liqiuqiui
Copy link
Contributor Author

内部是通过子组件的 props 来收集信息的,HOC 后你也需要把属性写到最外层才行。

jsx 结构本身是语法糖,是不支持 HOC 的。

好嘞,谢谢解答

@liqiuqiui
Copy link
Contributor Author

Dropdown.Item 的 props,是由Dropdown传下去的

套了一层相当于把它props隔离掉了,onClick自然也没设置到 Item 上

image

嗯嗯,后面看了代码后明白了。谢谢

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

No branches or pull requests

3 participants