You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Tabs component with TabList or TabPanels in combination with a .map to render a set of Tab or a set of TabPanel creates a forwardRef warning in devTools. Warning: Failed prop type: Invalid prop children supplied to ForwardRef(TabLists). Warning: Failed prop type: Invalid prop children supplied to ForwardRef(TabPanels).
To use a map over a list of objects is convenient when you have a long list, or the length is dynamic.
I was not able to replicate this bug using the example you provided...
exportconsttabsCollection=()=>{const[activeTab,setActiveTab]=useState(1)consthandleChange=(index)=>{setActiveTab(index)}constitems=[{name: 'Tab 1',value: 'Tab 1 body as plain text'},{name: 'Tab 2',value: <Typography>Tab 2 body as typography</Typography>},{name: 'Tab 3',value: <div>Tab 3 as div</div>},]return(<Wrapper><Typographyvariant="h1">
Tab with panels rendered from collection
</Typography><TabsactiveTab={activeTab}onChange={handleChange}><TabList>{items.map(({ name })=>(<Tabkey={name}>{name}</Tab>))}</TabList><TabPanels>{items.map(({ name, value })=>(<TabPanelkey={name}>{value}</TabPanel>))}</TabPanels></Tabs></Wrapper>)}
Although if I wrapped the Tab or TabPanel with styled-components I was able to reproduced this bug. 👨🎨
constStyledTab=styled(Tab)` background: pink;`constStyledTabPanel=styled(TabPanel)` background: peachpuff;`exportconsttabsCollection=()=>{const[activeTab,setActiveTab]=useState(1)consthandleChange=(index)=>{setActiveTab(index)}constitems=[{name: 'Tab 1',value: 'Tab 1 body as plain text'},{name: 'Tab 2',value: <Typography>Tab 2 body as typography</Typography>},{name: 'Tab 3',value: <div>Tab 3 as div</div>},]return(<Wrapper><Typographyvariant="h1">
Tab with panels rendered from collection
</Typography><TabsactiveTab={activeTab}onChange={handleChange}><TabList>{items.map(({ name })=>(<StyledTabkey={name}>{name}</StyledTab>))}</TabList><TabPanels>{items.map(({ name, value })=>(<StyledTabPanelkey={name}>{value}</StyledTabPanel>))}</TabPanels></Tabs></Wrapper>)}
Describe the bug
The Tabs component with TabList or TabPanels in combination with a .map to render a set of Tab or a set of TabPanel creates a forwardRef warning in devTools.
Warning: Failed prop type: Invalid prop
children
supplied toForwardRef(TabLists)
.Warning: Failed prop type: Invalid prop
children
supplied toForwardRef(TabPanels)
.To use a map over a list of objects is convenient when you have a long list, or the length is dynamic.
Steps to reproduce the bug
code example
Expected behavior
the same as if not using a map
The text was updated successfully, but these errors were encountered: