Skip to content

Commit f9b5cbb

Browse files
committed
[scheduler] Remove unnecessary useMemo usages
1 parent 47cd28c commit f9b5cbb

File tree

17 files changed

+25
-38
lines changed

17 files changed

+25
-38
lines changed

packages/x-scheduler-headless/src/calendar-grid/current-time-indicator/CalendarGridCurrentTimeIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const CalendarGridCurrentTimeIndicator = React.forwardRef(
5555
[position],
5656
);
5757

58-
const props = React.useMemo(() => ({ style }), [style]);
58+
const props = { style };
5959

6060
const isOutOfRange =
6161
adapter.isBefore(nowForColumn, columnStart) || adapter.isAfter(nowForColumn, columnEnd);

packages/x-scheduler-headless/src/calendar-grid/day-cell/CalendarGridDayCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const CalendarGridDayCell = React.forwardRef(function CalendarGridDayCell
2424
const { ref: listItemRef, index } = useCompositeListItem();
2525
const dropTargetRef = useDayCellDropTarget({ value, addPropertiesToDroppedEvent });
2626

27-
const props = React.useMemo(() => ({ role: 'gridcell' }), []);
27+
const props = { role: 'gridcell' };
2828

2929
const contextValue: CalendarGridDayCellContext = React.useMemo(
3030
() => ({

packages/x-scheduler-headless/src/calendar-grid/day-event-placeholder/CalendarGridDayEventPlaceholder.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { useRenderElement } from '../../base-ui-copy/utils/useRenderElement';
44
import { BaseUIComponentProps } from '../../base-ui-copy/utils/types';
55
import { useEvent } from '../../utils/useEvent';
66

7-
const EVENT_PLACEHOLDER_PROPS = { style: { pointerEvents: 'none' as const } };
8-
97
export const CalendarGridDayEventPlaceholder = React.forwardRef(
108
function CalendarGridDayEventPlaceholder(
119
componentProps: CalendarGridDayEventPlaceholder.Props,
@@ -27,7 +25,7 @@ export const CalendarGridDayEventPlaceholder = React.forwardRef(
2725
return useRenderElement('div', componentProps, {
2826
state,
2927
ref: [forwardedRef],
30-
props: [elementProps, EVENT_PLACEHOLDER_PROPS],
28+
props: [elementProps, { style: { pointerEvents: 'none' as const } }],
3129
});
3230
},
3331
);

packages/x-scheduler-headless/src/calendar-grid/day-event/CalendarGridDayEvent.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import { useEventCalendarStoreContext } from '../../use-event-calendar-store-con
1717
import { useCalendarGridDayCellContext } from '../day-cell/CalendarGridDayCellContext';
1818
import { useCalendarGridRootContext } from '../root/CalendarGridRootContext';
1919

20-
const EVENT_STYLE_WHILE_DRAGGING = { pointerEvents: 'none' as const };
21-
2220
export const CalendarGridDayEvent = React.forwardRef(function CalendarGridDayEvent(
2321
componentProps: CalendarGridDayEvent.Props,
2422
forwardedRef: React.ForwardedRef<HTMLDivElement>,
@@ -127,14 +125,11 @@ export const CalendarGridDayEvent = React.forwardRef(function CalendarGridDayEve
127125

128126
const columnHeaderId = getCalendarGridHeaderCellId(rootId, cellIndex);
129127

130-
const props = React.useMemo(
131-
() => ({
132-
id,
133-
'aria-labelledby': `${columnHeaderId} ${id}`,
134-
style: hasPlaceholder ? EVENT_STYLE_WHILE_DRAGGING : undefined,
135-
}),
136-
[hasPlaceholder, columnHeaderId, id],
137-
);
128+
const props = {
129+
id,
130+
'aria-labelledby': `${columnHeaderId} ${id}`,
131+
style: hasPlaceholder ? { pointerEvents: 'none' as const } : undefined,
132+
};
138133

139134
const contextValue: CalendarGridDayEventContext = React.useMemo(
140135
() => ({ ...draggableEventContextValue, getSharedDragData }),

packages/x-scheduler-headless/src/calendar-grid/day-row/CalendarGridDayRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const CalendarGridDayRow = React.forwardRef(function CalendarGridDayRow(
2121
...elementProps
2222
} = componentProps;
2323

24-
const props = React.useMemo(() => ({ role: 'row' }), []);
24+
const props = { role: 'row' };
2525
const cellsRefs = React.useRef<(HTMLDivElement | null)[]>([]);
2626

2727
const contextValue: CalendarGridDayRowContext = React.useMemo(

packages/x-scheduler-headless/src/calendar-grid/header-cell/CalendarGridHeaderCell.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ export const CalendarGridHeaderCell = React.forwardRef(function CalendarGridHead
4040
const { ref: listItemRef, index } = useCompositeListItem();
4141
const id = getCalendarGridHeaderCellId(rootId, index);
4242

43-
const props = React.useMemo(
44-
() => ({
45-
role: 'columnheader',
46-
id,
47-
'aria-label': `${adapter.formatByString(date.value, ariaLabelFormat)}`,
48-
}),
49-
[adapter, date, id, ariaLabelFormat],
50-
);
43+
const props = {
44+
role: 'columnheader',
45+
id,
46+
'aria-label': `${adapter.formatByString(date.value, ariaLabelFormat)}`,
47+
};
5148

5249
const state: CalendarGridHeaderCell.State = React.useMemo(
5350
() => ({

packages/x-scheduler-headless/src/calendar-grid/header-row/CalendarGridHeaderRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const CalendarGridHeaderRow = React.forwardRef(function CalendarGridHeade
1616
...elementProps
1717
} = componentProps;
1818

19-
const props = React.useMemo(() => ({ role: 'row' }), []);
19+
const props = { role: 'row' };
2020
const cellsRefs = React.useRef<(HTMLDivElement | null)[]>([]);
2121

2222
const element = useRenderElement('div', componentProps, {

packages/x-scheduler-headless/src/calendar-grid/root/CalendarGridRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const CalendarGridRoot = React.forwardRef(function CalendarGridRoot(
2020

2121
const id = useId(idProp);
2222

23-
const props = React.useMemo(() => ({ role: 'grid', id }), [id]);
23+
const props = { role: 'grid', id };
2424

2525
const contextValue: CalendarGridRootContext = React.useMemo(() => ({ id }), [id]);
2626

packages/x-scheduler-headless/src/calendar-grid/time-column/CalendarGridTimeColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const CalendarGridTimeColumn = React.forwardRef(function CalendarGridTime
4242
[isCurrentDay],
4343
);
4444

45-
const props = React.useMemo(() => ({ role: 'gridcell' }), []);
45+
const props = { role: 'gridcell' };
4646

4747
const contextValue: CalendarGridTimeColumnContext = React.useMemo(
4848
() => ({

packages/x-scheduler-headless/src/calendar-grid/time-event-placeholder/CalendarGridTimeEventPlaceholder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const CalendarGridTimeEventPlaceholder = React.forwardRef(
4141
[position, duration],
4242
);
4343

44-
const props = React.useMemo(() => ({ style }), [style]);
44+
const props = { style };
4545

4646
const { state } = useEvent({ start, end });
4747

0 commit comments

Comments
 (0)