feat(react): forward autoResize from useApp to App (#622)
useApp() previously hardcoded autoResize: true. Expose it as a hook option (default unchanged) so callers can disable the built-in ResizeObserver and drive sizing themselves.
This commit is contained in:
parent
94c94216d4
commit
4f89a6f8ea
1 changed files with 9 additions and 8 deletions
|
|
@ -12,14 +12,17 @@ export * from "../app";
|
||||||
/**
|
/**
|
||||||
* Options for configuring the {@link useApp `useApp`} hook.
|
* Options for configuring the {@link useApp `useApp`} hook.
|
||||||
*
|
*
|
||||||
* The `strict` option is forwarded to the underlying {@link App `App`}
|
* The `autoResize` and `strict` options are forwarded to the underlying
|
||||||
* instance. For other {@link AppOptions `AppOptions`}, create the `App`
|
* {@link App `App`} instance. For other {@link AppOptions `AppOptions`},
|
||||||
* manually instead of using this hook.
|
* create the `App` manually instead of using this hook.
|
||||||
*
|
*
|
||||||
* @see {@link useApp `useApp`} for the hook that uses these options
|
* @see {@link useApp `useApp`} for the hook that uses these options
|
||||||
* @see {@link useAutoResize `useAutoResize`} for manual auto-resize control with custom `App` options
|
* @see {@link useAutoResize `useAutoResize`} for manual auto-resize control with custom `App` options
|
||||||
*/
|
*/
|
||||||
export interface UseAppOptions extends Pick<AppOptions, "strict"> {
|
export interface UseAppOptions extends Pick<
|
||||||
|
AppOptions,
|
||||||
|
"autoResize" | "strict"
|
||||||
|
> {
|
||||||
/** App identification (name and version) */
|
/** App identification (name and version) */
|
||||||
appInfo: Implementation;
|
appInfo: Implementation;
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,6 +129,7 @@ export function useApp({
|
||||||
appInfo,
|
appInfo,
|
||||||
capabilities,
|
capabilities,
|
||||||
onAppCreated,
|
onAppCreated,
|
||||||
|
autoResize = true,
|
||||||
strict,
|
strict,
|
||||||
}: UseAppOptions): AppState {
|
}: UseAppOptions): AppState {
|
||||||
const [app, setApp] = useState<App | null>(null);
|
const [app, setApp] = useState<App | null>(null);
|
||||||
|
|
@ -141,10 +145,7 @@ export function useApp({
|
||||||
window.parent,
|
window.parent,
|
||||||
window.parent,
|
window.parent,
|
||||||
);
|
);
|
||||||
const app = new App(appInfo, capabilities, {
|
const app = new App(appInfo, capabilities, { autoResize, strict });
|
||||||
autoResize: true,
|
|
||||||
strict,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register handlers BEFORE connecting
|
// Register handlers BEFORE connecting
|
||||||
onAppCreated?.(app);
|
onAppCreated?.(app);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue