Tabs and CustomTabPane
See original GitHub issueHello,
Sorry I’m not a chinese speaking user and sorry this is not really an issue.
I’d like to know if it is possible to pass a custom TabPane
to Tabs
instead of a TabPane
component.
Exemple:
Classic:
import {Tabs} from 'antd';
const TabPane = Tabs.TabPane;
<Tabs defaultActiveKey='1' animated={false}>
<TabPane key={'1'} tab={<h4>One title</h4>}>
{some components that use props my_prop}
</TabPane>
<TabPane key={'2'} tab={<h4>Another title</h4>}>
{some components that use props my_prop}
</TabPane>
</Tabs>;
What I try to achieve:
import {Tabs} from 'antd';
const TabPane = Tabs.TabPane;
const CustomTabPane = ({key, my_prop, title}) =>
<TabPane key={key} tab={<h4>{title}</h4>}>
{some components that use props my_prop}
</TabPane>;
<Tabs defaultActiveKey='1' animated={false}>
<CustomTabPane key={'1'} my_prop={a} title="One title"/>
<CustomTabPane key={'2'} my_prop={b} title="Another Title"/>
</Tabs>;
The second Option does not display a thing. What should I add for using a custom component for Tabs
to be able to render my CustomTabPane
?
Thank you,
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:25 (17 by maintainers)
Top Results From Across the Web
Tabs - Ant Design
Ant Design has 3 types of Tabs for different situations. Card Tabs: for managing too many closeable views. Normal Tabs: for functional aspects...
Read more >Ant Design Custom Tabs with react Router v6 - Stack Overflow
i used the custom Tab in different occasion and i want to route each one of them specifically, for exemple url/Notifications/tab1, url/ ...
Read more >Tabs - Examples - Components - Atlassian Design System
Tabs are used to organize content by grouping similar information on the same page.
Read more >CustomTab element in the manifest file - Office Add-ins
Use the <CustomTab> element to add a custom tab to the ribbon. On custom tabs, the add-in can have custom or built-in groups....
Read more >CustomTab | Metadata API Developer Guide
Field Name Field Type Description
description string The optional description text for the tab.
fullName string
hasSidebar boolean Indicates if the tab displays the sidebar panel....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@paranoidjk Doing what you’re suggesting is not a good practice. React is about components and thinking with components. Not using interpolation hack everywhere… Also it will break rendering performance optimization. With this code, you cannot use
shouldComponentUpdate
and avoid some rendering. It’s a huge no no.Last thing, using high ordering component is very used in real life. You can for example write:
It allows us to completely control each component and its render cycle. It is easier to read and to understand. Using composition allow to change one of the component in the chain list and using the other. Overriding only the component we want. For example in a case of the html tag
table
, we know we can have atbody
,tr
,td
. If we define a component for each of these html tag based on our needs and use them. Further in the project we want to use them but with a different implementations oftr
for example. High ordering component composition allow you to only change this particular component thanks to … composition. Code will look this wayconst CustomTable = TableHOC(TableBodyHOC(MyNewTrHOC(Td)))
, and then pass your props toCustomTable
like you normally do. This is extremely powerful and reliable.I don’t know what’s going on with the current implementation of antd and customs TabPane not being recognized by Tabs… Not even a single error message is thrown… We can see the same use case with Material UI and Table component, it expects Tbody and Thead components. But you can use a custom component by adding it a
muiName
for making it works… I was looking for this kind of answer posting this issue.I don’t have the correct rights to reopen this issue. But one thing sure, this is not solved yet…
@GuillaumeCisco you just need to do this, pass down all restProps