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

Function addTab

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

Source from the content-addressed store, hash-verified

744 const [selectedTabId, setSelectedTabId] = useState(tabs[0].id);
745
746 let addTab = () => {
747 const tabId = tabs.length + 1;
748
749 setTabs(prevTabs => [
750 ...prevTabs,
751 {
752 id: tabId,
753 title: `Tab ${tabId}`,
754 content: `Tab body ${tabId}`
755 }
756 ]);
757
758 // Use functional update to ensure you're working with the most recent state
759 setSelectedTabId(tabId);
760 };
761
762 let removeTab = () => {
763 if (tabs.length > 1) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected