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

Destroy Inactive tab does not work when set at tab level #45338

Closed
ChuckJonas opened this issue Oct 13, 2023 · 2 comments · Fixed by react-component/tabs#675
Closed

Destroy Inactive tab does not work when set at tab level #45338

ChuckJonas opened this issue Oct 13, 2023 · 2 comments · Fixed by react-component/tabs#675

Comments

@ChuckJonas
Copy link
Contributor

ChuckJonas commented Oct 13, 2023

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • Create Tabs
  • Add a few items with destroyInactiveTabPane: true
  • Add a useEffect(() => alert('onMount'), [])
  • switch back and forth between tabs several times

What is expected?

If the component was destroyed when the tab is closed, the useEffect should fire every time the tab is opened.

What is actually happening?

It only fires the first time the tab is opened

Environment Info
antd 5.10.0
React 18.2
System any
Browser chromium

I tested with both the items prop and the children and got the same result. Also tried adding forceRender, but it doesn't do anything either.

It does work if you set the destroyInactiveTabPane at the component level, but in my cases this would be highly undesired to destroy all the tabs!

@Yuiai01
Copy link
Contributor

Yuiai01 commented Oct 13, 2023

I looked at the source code, and the destroyInactiveTabPane set at the component level is applied to the tab level.
https://github.com/react-component/tabs/blob/415ff34b8121e3353a11d8f640062fd966488603/src/TabPanelList/index.tsx#L35

@ChuckJonas
Copy link
Contributor Author

so... seems like a bug then?

The Tab Docs have no reference of the prop on the pane, but it's in the types.

Seems like it was intended to be put in place, but wasn't

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

Successfully merging a pull request may close this issue.

3 participants