Skip to main content

useActiveViewId

Get the view ID of currently active view, return a value of string. When views switched, re-rendering is triggered.

Returns

undefined | string

Example

import { useActiveViewId, useViewMeta } from '@apitable/widget-sdk';

// Render the currently selected view name
function ActiveView() {
const activeViewId = useActiveViewId();
const viewMeta = useViewMeta(activeViewId);
if (!viewMeta) {
return <p>Inactive view</p>
}
return <p>Currently active views: {viewMeta.name}</p>
}