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

Function renderMobileToc

packages/dev/s2-docs/src/OptimisticToc.tsx:42–60  ·  view source on GitHub ↗
(toc: TocNode[], seen = new Map())

Source from the content-addressed store, hash-verified

40}
41
42function renderMobileToc(toc: TocNode[], seen = new Map()) {
43 return toc.map(c => {
44 let href = c.level === 1 ? '#top' : '#' + anchorId(c.title);
45 if (seen.has(href)) {
46 seen.set(href, seen.get(href) + 1);
47 href += '-' + seen.get(href);
48 } else {
49 seen.set(href, 1);
50 }
51 return (
52 <React.Fragment key={href}>
53 <PickerItem id={href} href={href}>
54 {c.title}
55 </PickerItem>
56 {c.children.length > 0 && renderMobileToc(c.children, seen)}
57 </React.Fragment>
58 );
59 });
60}
61
62export function OptimisticToc() {
63 let {currentPage} = useRouter();

Callers 1

OptimisticMobileTocFunction · 0.85

Calls 3

anchorIdFunction · 0.70
hasMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected