Skip to content

Commit 85af0e9

Browse files
CopilotJCQuintas
andauthored
[charts] Remove useMemo from isZoomOn*Enabled and isPanOn*Enabled hooks (#20132)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JCQuintas <[email protected]>
1 parent 47cd28c commit 85af0e9

File tree

7 files changed

+11
-28
lines changed

7 files changed

+11
-28
lines changed

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ export const usePanOnDrag = (
2626
const startRef = React.useRef<readonly ZoomData[]>(null);
2727
const config = useSelector(store, selectorPanInteractionConfig, ['drag' as const]);
2828

29-
const isPanOnDragEnabled: boolean = React.useMemo(
30-
() => (Object.values(optionsLookup).some((v) => v.panning) && Boolean(config)) || false,
31-
[optionsLookup, config],
32-
);
29+
const isPanOnDragEnabled: boolean =
30+
Object.values(optionsLookup).some((v) => v.panning) && Boolean(config);
3331

3432
React.useEffect(() => {
3533
if (!isPanOnDragEnabled) {

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ export const usePanOnPressAndDrag = (
2626
const startRef = React.useRef<readonly ZoomData[]>(null);
2727
const config = useSelector(store, selectorPanInteractionConfig, ['pressAndDrag' as const]);
2828

29-
const isPanOnPressAndDragEnabled: boolean = React.useMemo(
30-
() => (Object.values(optionsLookup).some((v) => v.panning) && Boolean(config)) || false,
31-
[optionsLookup, config],
32-
);
29+
const isPanOnPressAndDragEnabled: boolean =
30+
Object.values(optionsLookup).some((v) => v.panning) && Boolean(config);
3331

3432
React.useEffect(() => {
3533
if (!isPanOnPressAndDragEnabled) {

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/useZoomOnBrush.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ export const useZoomOnBrush = (
2525
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
2626
const config = useSelector(store, selectorZoomInteractionConfig, ['brush' as const]);
2727

28-
const isZoomOnBrushEnabled: boolean = React.useMemo(
29-
() => (Object.keys(optionsLookup).length > 0 && Boolean(config)) || false,
30-
[optionsLookup, config],
31-
);
28+
const isZoomOnBrushEnabled: boolean = Object.keys(optionsLookup).length > 0 && Boolean(config);
3229

3330
React.useEffect(() => {
3431
instance.setZoomBrushEnabled(isZoomOnBrushEnabled);

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/useZoomOnDoubleTapReset.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ export const useZoomOnDoubleTapReset = (
2020
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
2121
const config = useSelector(store, selectorZoomInteractionConfig, ['doubleTapReset' as const]);
2222

23-
const isZoomOnDoubleTapResetEnabled: boolean = React.useMemo(
24-
() => (Object.keys(optionsLookup).length > 0 && Boolean(config)) || false,
25-
[optionsLookup, config],
26-
);
23+
const isZoomOnDoubleTapResetEnabled: boolean =
24+
Object.keys(optionsLookup).length > 0 && Boolean(config);
2725

2826
React.useEffect(() => {
2927
if (!isZoomOnDoubleTapResetEnabled) {

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ export const useZoomOnPinch = (
3131
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
3232
const config = useSelector(store, selectorZoomInteractionConfig, ['pinch' as const]);
3333

34-
const isZoomOnPinchEnabled: boolean = React.useMemo(
35-
() => (Object.keys(optionsLookup).length > 0 && Boolean(config)) || false,
36-
[optionsLookup, config],
37-
);
34+
const isZoomOnPinchEnabled: boolean = Object.keys(optionsLookup).length > 0 && Boolean(config);
3835

3936
React.useEffect(() => {
4037
if (!isZoomOnPinchEnabled) {

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ export const useZoomOnTapAndDrag = (
3131
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
3232
const config = useSelector(store, selectorZoomInteractionConfig, ['tapAndDrag' as const]);
3333

34-
const isZoomOnTapAndDragEnabled: boolean = React.useMemo(
35-
() => (Object.keys(optionsLookup).length > 0 && Boolean(config)) || false,
36-
[optionsLookup, config],
37-
);
34+
const isZoomOnTapAndDragEnabled: boolean =
35+
Object.keys(optionsLookup).length > 0 && Boolean(config);
3836

3937
React.useEffect(() => {
4038
if (!isZoomOnTapAndDragEnabled) {

packages/x-charts-pro/src/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ export const useZoomOnWheel = (
3333
const startedOutsideTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
3434
const config = useSelector(store, selectorZoomInteractionConfig, ['wheel' as const]);
3535

36-
const isZoomOnWheelEnabled: boolean = React.useMemo(
37-
() => (Object.keys(optionsLookup).length > 0 && Boolean(config)) || false,
38-
[optionsLookup, config],
39-
);
36+
const isZoomOnWheelEnabled: boolean = Object.keys(optionsLookup).length > 0 && Boolean(config);
4037

4138
React.useEffect(() => {
4239
if (!isZoomOnWheelEnabled) {

0 commit comments

Comments
 (0)