UNPKG

2.14 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2 } from "../../common";
3import { ResizeEntry } from "./resizeObserverTypes";
4export declare type ResizeSensorProps = IResizeSensorProps;
5/** @deprecated use ResizeSensorProps */
6export interface IResizeSensorProps {
7 /**
8 * Callback invoked when the wrapped element resizes.
9 *
10 * The `entries` array contains an entry for each observed element. In the
11 * default case (no `observeParents`), the array will contain only one
12 * element: the single child of the `ResizeSensor`.
13 *
14 * Note that this method is called _asynchronously_ after a resize is
15 * detected and typically it will be called no more than once per frame.
16 */
17 onResize: (entries: ResizeEntry[]) => void;
18 /**
19 * If `true`, all parent DOM elements of the container will also be
20 * observed for size changes. The array of entries passed to `onResize`
21 * will now contain an entry for each parent element up to the root of the
22 * document.
23 *
24 * Only enable this prop if a parent element resizes in a way that does
25 * not also cause the child element to resize.
26 *
27 * @default false
28 */
29 observeParents?: boolean;
30}
31/** `ResizeSensor` requires a single DOM element child and will error otherwise. */
32export declare class ResizeSensor extends AbstractPureComponent2<ResizeSensorProps> {
33 static displayName: string;
34 private element;
35 private observer;
36 render(): string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactPortal | null | undefined;
37 componentDidMount(): void;
38 componentDidUpdate(prevProps: ResizeSensorProps): void;
39 componentWillUnmount(): void;
40 /**
41 * Observe the DOM element, if defined and different from the currently
42 * observed element. Pass `force` argument to skip element checks and always
43 * re-observe.
44 */
45 private observeElement;
46 private getElement;
47}
48
\No newline at end of file