Initial commit
This commit is contained in:
commit
92f42cf533
1 changed files with 2534 additions and 0 deletions
20
react/useAutoResize.ts
Normal file
20
react/useAutoResize.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useEffect, RefObject } from "react";
|
||||
import { App } from "../app";
|
||||
|
||||
/**
|
||||
* Custom hook that automatically reports size changes to the parent window.
|
||||
*
|
||||
* @param client - MCP UI client for sending size notifications
|
||||
*/
|
||||
export function useAutoResize(
|
||||
app: App | null,
|
||||
elementRef?: RefObject<HTMLElement | null>,
|
||||
) {
|
||||
useEffect(() => {
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
return app.setupSizeChangeNotifications();
|
||||
}, [app, elementRef]);
|
||||
}
|
||||
Loading…
Reference in a new issue