diff --git a/.changeset/short-turkeys-matter.md b/.changeset/short-turkeys-matter.md new file mode 100644 index 0000000..2abd4db --- /dev/null +++ b/.changeset/short-turkeys-matter.md @@ -0,0 +1,5 @@ +--- +"react-headless-tabs": patch +--- + +Only unmount hidden inactive tabs diff --git a/packages/lib/src/TabPanel.tsx b/packages/lib/src/TabPanel.tsx index 3d95563..99b26f0 100644 --- a/packages/lib/src/TabPanel.tsx +++ b/packages/lib/src/TabPanel.tsx @@ -44,7 +44,10 @@ export function TabPanel({ } if (typeof unmount === "number") { - unmountRef.current = wait(() => setShouldRender(false), unmount * 1000); + unmountRef.current = wait( + () => setShouldRender(!props.hidden), + unmount * 1000 + ); } return () => {