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

Function Row

packages/react-aria/stories/grid/example.tsx:68–105  ·  view source on GitHub ↗
({state, item, focusMode})

Source from the content-addressed store, hash-verified

66}
67
68function Row({state, item, focusMode}) {
69 let rowRef = React.useRef(null);
70 let cellRef = React.useRef(null);
71 let cellNode = [...item.childNodes][0];
72 let {rowProps} = useGridRow({node: item}, state, rowRef);
73 let {gridCellProps} = useGridCell(
74 {
75 node: cellNode,
76 focusMode
77 },
78 state,
79 cellRef
80 );
81
82 let [isRowFocused, setRowFocused] = React.useState(false);
83 let {focusProps: rowFocusProps} = useFocus({
84 onFocusChange: setRowFocused
85 });
86
87 let [isCellFocused, setCellFocused] = React.useState(false);
88 let {focusProps: cellFocusProps} = useFocus({
89 onFocusChange: setCellFocused
90 });
91
92 return (
93 <div
94 {...mergeProps(rowProps, rowFocusProps)}
95 ref={rowRef}
96 style={{outline: isRowFocused ? '2px solid red' : undefined}}>
97 <div
98 {...mergeProps(gridCellProps, cellFocusProps)}
99 ref={cellRef}
100 style={{outline: isCellFocused ? '2px solid green' : undefined}}>
101 {cellNode.rendered}
102 </div>
103 </div>
104 );
105}

Callers

nothing calls this directly

Calls 4

useGridRowFunction · 0.90
useGridCellFunction · 0.90
useFocusFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected