portal icon indicating copy to clipboard operation
portal copied to clipboard

Uncaught Error: Maximum update depth exceeded.

Open LenkasetSong opened this issue 5 months ago • 5 comments

react-dom-client.development.js:3860 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 getRootForUpdatedFiber (react-dom-client.development.js:3860:1) at enqueueConcurrentHookUpdate (react-dom-client.development.js:3820:1) at dispatchSetStateInternal (react-dom-client.development.js:6966:1) at dispatchSetState (react-dom-client.development.js:6927:1) at Portal.js:63:1 at Object.react_stack_bottom_frame (react-dom-client.development.js:23953:1) at runWithFiberInDEV (react-dom-client.development.js:1519:1) at commitHookEffectListMount (react-dom-client.development.js:11905:1) at commitHookPassiveMountEffects (react-dom-client.development.js:12026:1) at commitPassiveMountOnFiber (react-dom-client.development.js:13841:1)

https://github.com/react-component/portal/blob/master/src/Portal.tsx

React.useEffect(() => { const customizeContainer = getPortalContainer(getContainer);

// Tell component that we check this in effect which is safe to be `null`
setInnerContainer(customizeContainer ?? null);

}); 是不是此处导致的,还是我外部使用不对导致的?

LenkasetSong avatar Sep 03 '25 02:09 LenkasetSong

antd : Slider的tooltip会导致这种情况 Tooltip

如果类似这样的用法: {state <= 10000 && <Slider min={1} max={10000} value={state} tooltip={undefined} onChange={(v) => setState(v)} />}

可能是antd的bug

LenkasetSong avatar Sep 04 '25 05:09 LenkasetSong

Same exact issue

James-Jager avatar Nov 10 '25 19:11 James-Jager

It causes the same issue in rc-picker

litvinenko-rc avatar Nov 18 '25 21:11 litvinenko-rc

I have created a PR for this issue: https://github.com/react-component/portal/pull/29

James-Jager avatar Nov 19 '25 14:11 James-Jager

If you need a fix right away I just used patch-package made the changes needed(see PR) and generate the post install patch.

James-Jager avatar Nov 19 '25 14:11 James-Jager