Skip to content

Commit d22c5aa

Browse files
committed
[composite] Remove unnecessary props memos
1 parent f05111c commit d22c5aa

3 files changed

Lines changed: 213 additions & 247 deletions

File tree

packages/react/src/internals/composite/item/useCompositeItem.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,23 @@ export function useCompositeItem<Metadata>(params: UseCompositeItemParameters<Me
2323
const itemRef = React.useRef<HTMLElement | null>(null);
2424
const mergedRef = useMergedRefs(ref, itemRef);
2525

26-
const compositeProps = React.useMemo<HTMLProps>(
27-
() => ({
28-
tabIndex: isHighlighted ? 0 : -1,
29-
onFocus() {
30-
onHighlightedIndexChange(index);
31-
},
32-
onMouseMove() {
33-
const item = itemRef.current;
34-
if (!highlightItemOnHover || !item) {
35-
return;
36-
}
26+
const compositeProps: HTMLProps = {
27+
tabIndex: isHighlighted ? 0 : -1,
28+
onFocus() {
29+
onHighlightedIndexChange(index);
30+
},
31+
onMouseMove() {
32+
const item = itemRef.current;
33+
if (!highlightItemOnHover || !item) {
34+
return;
35+
}
3736

38-
const disabled = item.hasAttribute('disabled') || item.ariaDisabled === 'true';
39-
if (!isHighlighted && !disabled) {
40-
item.focus();
41-
}
42-
},
43-
}),
44-
[isHighlighted, onHighlightedIndexChange, index, highlightItemOnHover],
45-
);
37+
const disabled = item.hasAttribute('disabled') || item.ariaDisabled === 'true';
38+
if (!isHighlighted && !disabled) {
39+
item.focus();
40+
}
41+
},
42+
};
4643

4744
return {
4845
compositeProps,

packages/react/src/internals/composite/list/useCompositeListItem.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,5 @@ export function useCompositeListItem<Metadata>(
9999
});
100100
}, [externalIndex, subscribeMapChange, setIndex]);
101101

102-
return React.useMemo(
103-
() => ({
104-
ref,
105-
index,
106-
}),
107-
[index, ref],
108-
);
102+
return { ref, index };
109103
}

0 commit comments

Comments
 (0)