useSpatialWindowState Hook
Returns the current placement state of a spatial window.
Pass a window label to observe it from anywhere beneath the scene provider,
or omit the label when calling from within that <SpatialWindow>.
placement reports 'inline', 'pending', 'spatial', or 'dropped'.
wasEverInline distinguishes a first promotion from a later promotion of
content that the user has already seen inline.
Before the system reports a placement, the hook returns {placement:
'inline', wasEverInline: false}. Calling it without a label and outside a
spatial window returns the same default and warns during development.
Observe a window by label.
import {useSpatialWindowState} from '@metavr/layout-window-compat';
function DetailsStatus() {
const {placement} = useSpatialWindowState('recipe-details');
return <Text>{placement}</Text>;
}
Observe the nearest enclosing window.
import {
SpatialWindow,
useSpatialWindowState,
} from '@metavr/layout-window-compat';
function WindowContent() {
const {placement, wasEverInline} = useSpatialWindowState();
return <Status placement={placement} wasEverInline={wasEverInline} />;
}
<SpatialWindow
label="details"
windowWidth={360}
windowHeight={480}>
<WindowContent />
</SpatialWindow>
useSpatialWindowState(label?: string): SpatialWindowState