Skip to content

Commit

Permalink
Updated react dockview-demo CodeSandbox to reset relevant state on su…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
zaxer2 authored Jan 3, 2025
1 parent 148a05a commit cd91f4a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ const DockviewDemo = (props: { theme?: string }) => {

const onReady = (event: DockviewReadyEvent) => {
setApi(event.api);
setPanels([]);
setGroups([]);
setActivePanel(undefined);
setActiveGroup(undefined);
addLogLine(`Dockview Is Ready`);

event.api.onDidAddPanel((event) => {
setPanels((_) => [..._, event.id]);
Expand Down

0 comments on commit cd91f4a

Please sign in to comment.