MCPcopy Create free account
hub / github.com/adobe/react-spectrum / removeTab

Function removeTab

packages/react-aria-components/test/Tabs.test.js:762–772  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

760 };
761
762 let removeTab = () => {
763 if (tabs.length > 1) {
764 setTabs(prevTabs => {
765 const updatedTabs = prevTabs.slice(0, -1);
766 // Update selectedTabId to the last remaining tab's ID if the current selected tab is removed
767 const newSelectedTabId = updatedTabs[updatedTabs.length - 1].id;
768 setSelectedTabId(newSelectedTabId);
769 return updatedTabs;
770 });
771 }
772 };
773
774 const onSelectionChange = value => {
775 setSelectedTabId(value);

Callers

nothing calls this directly

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected