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

Fixing duplicate state in React-Dockview-Demo caused by strict mode #816

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zaxer2
Copy link

@zaxer2 zaxer2 commented Jan 3, 2025

Currently, the Dockview-Demo on CodeSandbox looks like this:
image

As far as I can tell, This seems to be because strict mode causes the Dockview to load, unload, then load again, which causes onReady to be called twice, which causes DefaultLayout to be called twice, which puts two copies of the default layout into state. (Groups state & Panels state)

As I see it, there are a few possible solutions here:

  1. Dockview could be changed to call each onDidRemoveGroup and onDidRemovePanel hook while unloading, causing Group and Panel state to update naturally in their associated hooks.

  2. Dockview could expose an onWillUnload hook, mirror to the onReady hook, that gets called when Dockview starts unloading. Then, state resets could be placed in there.

  3. You can just place your state resets in onReady. This is the band-aid fix I'm proposing here.

Either way, at the end of it the Dockview-Demo codesandbox should look like this. This is the intent of this pull request.

image

zaxer2 added 2 commits January 3, 2025 13:22
…bsequent onReady calls

Strict Mode causes the Dockview component to render twice, causing onReady to be called twice, which puts two copies of DefaultLayout in state without resetting between calls.

A most-ideal solution would probably be to expose an onUnload hook or something like that, to be called after one onReady but before the next. Then, the state resets could be called in that hook. but this fix will at least ensure the Dockview-Demo codesandbox behaves nicely for the time being.
Copy link

codesandbox-ci bot commented Jan 3, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 10fd577:

Sandbox Source
customheader-dockview Configuration
dockview-app Configuration
editor-gridview Configuration
externaldnd-dockview Configuration
fullwidthtab-dockview Configuration
iframe-dockview Configuration
keyboard-dockview Configuration
nativeapp-dockview Configuration
rendering-dockview Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant