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

Function TabsInner

starters/hooks/src/Tabs.tsx:64–95  ·  view source on GitHub ↗
({
  collection,
  ...props
}: AriaTabListOptions<object> &
  Omit<TabListStateOptions<object>, 'children'> & {
    collection: ICollection<Node<object>>;
  })

Source from the content-addressed store, hash-verified

62}
63
64function TabsInner({
65 collection,
66 ...props
67}: AriaTabListOptions<object> &
68 Omit<TabListStateOptions<object>, 'children'> & {
69 collection: ICollection<Node<object>>;
70 }) {
71 let state = useTabListState({...props, collection, children: undefined});
72 let ref = useRef<HTMLDivElement>(null);
73 /*- begin highlight -*/
74 let {tabListProps} = useTabList(props, state, ref);
75 /*- end highlight -*/
76 let orientation = props.orientation || 'horizontal';
77
78 return (
79 <div className="react-aria-Tabs" data-orientation={orientation}>
80 <div
81 {...tabListProps}
82 ref={ref}
83 className="react-aria-TabList"
84 data-orientation={orientation}>
85 <TabListStateContext.Provider value={state}>
86 {[...state.collection].map(item => (
87 <Fragment key={item.key}>{item.render!(item)}</Fragment>
88 ))}
89 </TabListStateContext.Provider>
90 </div>
91 {/* Re-mount the panel when the selection changes so DOM state isn't shared between tabs. */}
92 <TabPanel key={state.selectedItem?.key} state={state} />
93 </div>
94 );
95}
96
97function TabPanel({state, ...props}: {state: TabListState<object>}) {
98 let ref = useRef<HTMLDivElement>(null);

Callers

nothing calls this directly

Calls 2

useTabListStateFunction · 0.90
useTabListFunction · 0.90

Tested by

no test coverage detected