You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dockview has two rendering modes `onlyWhenVisible` (default) and `always`. A rendering mode can be defined through the `renderer` prop to `DockviewReact` or at an individual panel level when added where
568
+
the panel declaration takes precedence if both are defined. Rendering modes defined at the panel level are persisted, those defined at the `DockviewReact` level are not persisted.
569
+
570
+
-`onlyWhenVisible` mode is the default mode. In this mode when a panel is no longer visible through either it's visiblity being hidden or it not being the active panel within a group the panels HTMLElement is removed
571
+
from the DOM and any DOM state such as scrollbar positions will be lost. If you are using any ResizeObservers to measure size this will result both zero height and width as the HTMLElement no longer belongs to the DOM.
572
+
This design allows for maximum performance at some cost.
573
+
-`always` mode. In this mode when panels become hidden the HTMLElement is not destroyed so all DOM state such as scrollbar positions will be maintained. This is implemented by rendering each panel as an absolutely positioned
574
+
HTMLElement and hidden the HTMLElement with `display: none` when it should be hidden.
575
+
576
+
<MultiFrameworkContainer
577
+
height={500}
578
+
sandboxId="rendermode-dockview"
579
+
react={DockviewRenderMode}
580
+
/>
581
+
582
+
####
583
+
566
584
By default `DockviewReact` only adds to the DOM those panels that are visible,
567
585
if a panel is not the active tab and not shown the contents of the hidden panel will be removed from the DOM.
568
586
569
-
However the React Components associated with each panel are only created once and will always exist for as long as the panel exists, hidden or not.
587
+
When a panel is in `onlyWhenVisible` render mode this only affects the contents within the DOM. The lifecycle of that panel instance is still maintained.
588
+
The React Components associated with each panel are only created once and will always exist for as long as the panel exists, hidden or not.
570
589
571
-
> For example this means that any hooks in those components will run whether the panel is visible or not which may lead to excessive background work depending
590
+
> e.g. This means that any hooks in those components will run whether the panel is visible or not which may lead to excessive background work depending
572
591
> on the panels implementation.
573
592
574
-
This is the default behaviour to ensure the greatest flexibility for the user but through the panels `props.api` you can listen to the visiblity state of the panel
575
-
and write additional logic to optimize your application.
593
+
You can listen to the visiblity state of the panel and write additional logic to optimize your application if required, although this is an advanced case.
576
594
577
-
For example if you wanted to unmount the React Components when the panel is not visible you could create a Higher-Order-Component that listens to the panels
595
+
If you wanted to unmount the React Components when the panel is not visible you could create a Higher-Order-Component that listens to the panels
578
596
visiblity state and only renders the panel when visible.
579
597
580
598
```tsx title="Only rendering the React Component when the panel is visible, otherwise rendering a null React Component"
Toggling the checkbox you can see that when you only render those panels which are visible the underling React component is destroyed when it becomes hidden and re-created when it becomes visible.
Dockview has two rendering modes `destructive` (default) and `gready`. A rendering mode can be defined through the `renderer` prop to `DockviewReact` or at an individual panel level when added where
857
-
the panel declaration takes precedence if both are defined. Rendering modes defined at the panel level are persisted, those defined at the `DockviewReact` level are not persisted.
858
-
859
-
destructive
860
-
- Destructive mode is the default mode. In this mode when a panel is no longer visible through either it's visiblity being hidden or it not being the active panel within a group the panels HTMLElement is removed
861
-
from the DOM and any DOM state such as scrollbar positions will be lost. If you are using any ResizeObservers to measure size this will result both zero height and width as the HTMLElement no longer belongs to the DOM.
862
-
This design allows for maximum performance at some cost.
863
-
- Gready mode. In this mode when panels become hidden the HTMLElement is not destroyed so all DOM state such as scrollbar positions will be maintained. This is implemented by rendering each panel as an absolutely positioned
864
-
HTMLElement and hidden the HTMLElement with `display: none` when it should be hidden.
0 commit comments