Merge pull request #816 from zaxer2/Making-React-Dockview-Demo-work-nice-with-Strict-Mode

Fixing duplicate state in React-Dockview-Demo caused by strict mode
This commit is contained in:
mathuo 2025-01-11 14:33:28 +00:00 committed by GitHub
commit c7c1ae9238
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -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]);

View File

@ -124,6 +124,11 @@ const DockviewDemo = (props: { theme?: string }) => {
const onReady = (event: DockviewReadyEvent) => {
setApi(event.api);
setPanels([]);
setGroups([]);
setActivePanel(undefined);
setActiveGroup(undefined);
addLogLine(`Dockview Is Ready`);
};
React.useEffect(() => {