Context & Patterns — Intermediate React challenge.
Build a Tabs component using the 'compound components' pattern — Tabs, Tabs.List, Tabs.Tab, Tabs.Panels, and Tabs.Panel work together, sharing active-tab state implicitly through Context instead of the consumer wiring up index/state props by hand.
function Tabs({ defaultIndex?: number; children: React.ReactNode }): JSX.Element
Tabs.List, Tabs.Tab({ index }), Tabs.Panels, Tabs.Panel({ index })<Tabs defaultIndex={0}>
<Tabs.List>
<Tabs.Tab index={0}>Profile</Tabs.Tab>
<Tabs.Tab index={1}>Settings</Tabs.Tab>
</Tabs.List>
<Tabs.Panels>
<Tabs.Panel index={0}>Profile content</Tabs.Panel>
<Tabs.Panel index={1}>Settings content</Tabs.Panel>
</Tabs.Panels>
</Tabs>
// clicking the "Settings" tab swaps the visible panel