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
A List of antd
's components that cannot work with HOC
#4853
Comments
It's difficult, for some components use key => id
expandedKeys => expandedIds
selectedKeys => selectedIds
.... It will be a breaking change, but such kind of breaking change can be resolve by antd-codemod. |
SO, do you think that it is worthy doing so? |
This comment has been minimized.
This comment has been minimized.
Not fan of codemod solution. Embedding components into custom components is a common practice in React. Please fix it and see ant-design adoption fast increase with no doubt. Ant Design is really appealing and is the first library that makes me want to leave react-bootstrap. |
|
@afc163 if we cannot rename those APIs, then we can not resolve this problem. But we can provide a work around, see: react-component/collapse#73 (comment) Do you think that we should add this to documentation? |
@benjycui I understand. Anyway, it is not blocking after all. Thank you for taking time answering. |
@benjycui I was investigating the workaround you proposed but I think it is not a proper solution. Usually when you wrap a component you want also to have some internal state. With the solution proposed this is not possible. |
Agreed to say this is not a small problem and it's something I did not expect of when I started using Ant Design library, the good practice of custom components are used throughout React projects. Personally, I really like Ant Design, but for some, this could be a dealbreaker. Would really love to see this gets improved in the upcoming Ant Design v3. |
Please find a solution for this in v3. |
Can be resolved after this package released (maybe). |
just ran into this trying (sorry if this is wrong) to create a navbar using menu and nesting React Router Is there a more preferred solution? |
IMHO, this thread should be in the official docs, because this issue is likely to be a dealbreaker for many users. |
I would have definitely appreciated mention of this in the documentation! I was trying to do something like this and wasted quite a bit of time because it doesn't work.
Where Also, now that react16 allows you to return arrays of components from render, being able to do this would be especially helpful. Otherwise, prevent duplicate code is challenging. |
Any updates on this? |
Cant create a HOC/custom component around Column component for code splitting & custom handling, using |
For Typescript users out there: If you want to wrap inner components like
You can see what's happening under the hood here: The You can also override whichever props you want like
|
If you want to pass other props beside PanelWrapperProps you can do it like this:
|
For posterity, I thought I'd share a workaround (hack?) that partially works for Tabs and may work for other components that ant-design doesn't allow to be extended by an HoC. Take a look at this example. As you can see, it requires the wrapper component to be called in a function manner rather than via JSX. It's an atypical DX, for sure.... The biggest remaining limitation for me, though, is that you can't control the |
Is there an update now...? Low priority should also be considered. |
God, I'm sorry for the late response. #4853 (comment) |
Still no workaround for Descriptions.Item ? |
It is not a common use case, so it's low priority. But we still can discuss and try to make it better:
Menu
Menu.SubMenu
Menu.MenuItem
, cannot be wrapped for keyboard operations rely oninstance.onKeyDown
Menu 组件focus状态,按方向键会报错:Uncaught TypeError: obj.onKeyDown is not a function #4849Table.Column
, forTable
will readchildren[n].props
as config and it cannot not read children's ownee's props now jsx风格的Table Column API提供自定义Column支持 #4029 Allow Table.Column class type to be possible to extend as a generic type in TypeScript #4324Collpase.Panel
, forCollapse
will readchildren[n].header
as title.Tabs.TabPane
, forTabs
will readchildren[n].tab
to generate TabBar. Tabs and CustomTabPane #5165Select.Option
, forSelect
depends onkey
prop on Option.Descriptions.Item
DescriptionItem not support hoc #27411The text was updated successfully, but these errors were encountered: