State reset when switching tabs and forceRender render tabpanel on each tabpanel
Hello, Im trying to make an add / delete feature with react-tabs. Im able to delete and add. But when I switch tabs the state keep reseting. So I searched and find forceRender and forceRenderTabPanel. I tried both but when I use them every tabpanel is rendering in each tabpanel. I think there is a problem with my map or this is an issue. Here is a not working example:
https://codesandbox.io/s/late-http-epp5n?fontsize=14
When I use basic tabs without add and delete functions everything works fine.
Have you resolved this? I have the same issue and the forceRender props don't appear to have any affect.
I am also having the same issue.
I managed to solve it by using the prop without using a Boolean value, so
<Tags ... forceRenderTabsPanel> ... </Tags>
Did the job.
I managed to solve it by using the prop without using a Boolean value, so
<Tags ... forceRenderTabsPanel> ... </Tags>Did the job.
I tried this, how did you get past the issue of all the TabPanel's showing?
That's a CSS issue, @DexSnake. If you forceRender panels, they will stay mounted in the DOM. You'll need to write some CSS to display only the selected tab. For the default classnames, this could look something like the following (taken from the default styles — https://github.com/reactjs/react-tabs/blob/25cfa16/style/react-tabs.css#L50-L56):
.react-tabs__tab-panel {
display: none;
}
.react-tabs__tab-panel--selected {
display: block;
}
Or, if you don't want to explicitly set the display property of the selected <TabPanel/>:
.react-tabs__tab-panel:not(.react-tabs__tab-panel--selected) {
display: none;
}
That's a CSS issue, @DexSnake. If you
forceRenderpanels, they will stay mounted in the DOM. You'll need to write some CSS to display only the selected tab. For the default classnames, this could look something like the following (taken from the default styles — https://github.com/reactjs/react-tabs/blob/25cfa16/style/react-tabs.css#L50-L56):.react-tabs__tab-panel { display: none; } .react-tabs__tab-panel--selected { display: block; }Or, if you don't want to explicitly set the
displayproperty of the selected<TabPanel/>:.react-tabs__tab-panel:not(.react-tabs__tab-panel--selected) { display: none; }
Ahhh, this makes sense. Thanks for the reply!