-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Fix DockLayout.updateTabCache #214
base: master
Are you sure you want to change the base?
Fix DockLayout.updateTabCache #214
Conversation
@rinick @slavamuravey does this look right to you? |
Can someone please fix this bug? |
This seems like a known issue. It's frustrating that the layout crashes occasionally. If this pull request fixes the problem, it would be great to merge it to the main branch. |
src/DockLayout.tsx
Outdated
@@ -161,6 +161,9 @@ class DockPortalManager extends React.PureComponent<LayoutProps, LayoutState> { | |||
updateTabCache(id: string, children: React.ReactNode): void { | |||
let cache = this._caches.get(id); | |||
if (cache) { | |||
if (Object.is(cache.portal?.children, children)) { | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add semicolon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added!
Applied temporary Here's an example: https://codesandbox.io/s/cycle-update-bug-vdphjp?file=/src/App.tsx Drag a bunch of This might be related to the |
@garyvh2 looks like the tabs in your example are unstable. Their randomly generated |
I've updated the solution in this case removing the I've updated the example with a simple count on the outside, which is set on drag n drop, and also used the prior id on |
Can someone approve this? We get similar error for React 18 floating tabs when window is resized and it crashes the app. react-dom.development.js:27292 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. |
Hello @Shravankumarkarnati could you please approve this fix? |
Fixes #198, #195
This seems to be a problem with useEffect running twice in React 18 StrictMode.
Fixed it by adding an equality check on current cache and given children to update.
Only update the cache (and forceUpdate) if they are not same.