Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Resizable dragging caused Max Depth Exceeded in ReactJS #6901

Open
2 tasks done
lawrencenika opened this issue Mar 10, 2025 · 1 comment
Open
2 tasks done

[bug]: Resizable dragging caused Max Depth Exceeded in ReactJS #6901

lawrencenika opened this issue Mar 10, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@lawrencenika
Copy link

Describe the bug

console error of

react-dom.development.js:26793 Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

was observed when I was dragging the ResizableHandler left and right multiple times.

Affected component/components

Resizable

How to reproduce

/package.json:
"react-resizable-panels": "^2.1.7",
...

/components/ui/resizable.tsx:

'use client';

import type React from 'react';

import * as ResizablePrimitive from 'react-resizable-panels';
import { GripVertical } from 'lucide-react';

import { cn } from '@/lib/utils';

const ResizablePanelGroup = ({
    className,
    ...props
}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
    <ResizablePrimitive.PanelGroup
        className={cn(
            'flex h-full w-full data-[panel-group-direction=vertical]:flex-col',
            className,
        )}
        {...props}
    />
);

const ResizablePanel = ResizablePrimitive.Panel;

const ResizableHandle = ({
    withHandle,
    className,
    ...props
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
    withHandle?: boolean;
}) => (
    <ResizablePrimitive.PanelResizeHandle
        className={cn(
            'relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90',
            className,
        )}
        {...props}
    >
        {withHandle && (
            <div className='z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border'>
                <GripVertical className='h-2.5 w-2.5' />
            </div>
        )}
    </ResizablePrimitive.PanelResizeHandle>
);

export { ResizablePanelGroup, ResizablePanel, ResizableHandle };

Codesandbox/StackBlitz link

No response

Logs

react-dom.development.js:26793 Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
at throwIfInfiniteUpdateLoopDetected (react-dom.development.js:26793:11)
    at getRootForUpdatedFiber (react-dom.development.js:7627:3)
    at enqueueConcurrentHookUpdate (react-dom.development.js:7518:10)
    at dispatchSetState (react-dom.development.js:13073:16)
    at resizeHandler (react-resizable-panels.browser.development.esm.js:2122:9)
    at setResizeHandlerState (react-resizable-panels.browser.development.esm.js:2449:15)
    at eval (react-resizable-panels.browser.development.esm.js:715:5)
    at Set.forEach (<anonymous>)
    at updateResizeHandlerStates (react-resizable-panels.browser.development.esm.js:710:28)
    at HTMLBodyElement.handlePointerMove (...

System Info

Tried both Arc and Chrome browsers, got the same error.

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@lawrencenika lawrencenika added the bug Something isn't working label Mar 10, 2025
@lawrencenika
Copy link
Author

I might found the code that caused this error, in react-resizable-panels.development.node.esm.js:

const resizeHandleId = useUniqueId(idFromProps);
const [state, setState] = useState("inactive");
const [isFocused, setIsFocused] = useState(false);
const [resizeHandler, setResizeHandler] = useState(null);
const committedValuesRef = useRef({
  state
});
useEffect(() => {
  if (disabled) {
    setResizeHandler(null);
  } else {
    const resizeHandler = registerResizeHandleWithParentGroup(resizeHandleId);
    setResizeHandler(() => resizeHandler);
  }
}, [disabled, resizeHandleId, registerResizeHandleWithParentGroup]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant