mirror of
https://github.com/mathuo/dockview
synced 2025-02-02 06:25:44 +00:00
Updated react dockview-demo CodeSandbox to reset relevant state on subsequent 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.
This commit is contained in:
parent
148a05a201
commit
cd91f4a4d3
@ -178,6 +178,11 @@ const DockviewDemo = (props: { theme?: string }) => {
|
|||||||
|
|
||||||
const onReady = (event: DockviewReadyEvent) => {
|
const onReady = (event: DockviewReadyEvent) => {
|
||||||
setApi(event.api);
|
setApi(event.api);
|
||||||
|
setPanels([]);
|
||||||
|
setGroups([]);
|
||||||
|
setActivePanel(undefined);
|
||||||
|
setActiveGroup(undefined);
|
||||||
|
addLogLine(`Dockview Is Ready`);
|
||||||
|
|
||||||
event.api.onDidAddPanel((event) => {
|
event.api.onDidAddPanel((event) => {
|
||||||
setPanels((_) => [..._, event.id]);
|
setPanels((_) => [..._, event.id]);
|
||||||
|
Loading…
Reference in New Issue
Block a user