useViewport
Return information related to the widget windows, and change function. When windows changes, re-rendering is triggered.
Returns
Object
Example
import { useViewport } from '@apitable/widget-sdk';
// Full-screen display and control of the widget
function Viewport() {
const { isFullscreen, toggleFullscreen } = useViewport();
return (<div>
<p>Widget expand full screen: {isFullscreen ? 'yes' : 'no'}</p>
<button onClick={() => toggleFullscreen()}>Tap me to switch the widget to expand</button>
</div>);
}
Name | Type |
---|---|
isFullscreen | boolean |
toggleFullscreen | (state? : boolean ) => void |