[react-visibility-sensor] Updated to v5. (#30356)

* Updated to react-visibility-sensor v5.

* Include null for isVisible on child function arg.
This commit is contained in:
gcangussu
2018-11-14 11:00:16 -08:00
committed by Pranav Senthilnathan
parent c59c711d65
commit 696ea3460b
2 changed files with 23 additions and 8 deletions
+12 -5
View File
@@ -1,6 +1,7 @@
// Type definitions for react-visibility-sensor 3.11
// Type definitions for react-visibility-sensor 5.0
// Project: https://github.com/joshwnj/react-visibility-sensor#readme
// Definitions by: Rasmus Bergström <https://github.com/JRasmusBm>
// Gabriel Cangussu <https://github.com/gcangussu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -15,8 +16,15 @@ interface Shape {
right?: number;
}
interface ChildFunctionArg {
isVisible: boolean | null;
visibilityRect: Shape;
}
type ChildFunction = (arg: ChildFunctionArg) => React.ReactNode;
interface Props {
onChange: (isVisible: boolean, visibilityRect?: Shape) => void;
onChange?: (isVisible: boolean) => void;
active?: boolean;
partialVisibility?: boolean;
offset?: Shape;
@@ -29,10 +37,9 @@ interface Props {
resizeCheck?: boolean;
resizeDelay?: number;
resizeThrottle?: number;
containment?: HTMLElement;
delayedCall?: boolean;
children?: (
args: { isVisible: boolean; visibilityRect?: Shape }
) => React.ReactNode;
children?: React.ReactElement<any> | ChildFunction;
}
declare const ReactVisibilitySensor: React.StatelessComponent<Props>;
@@ -8,7 +8,7 @@ const shape = { top: num, left: num, bottom: num, right: num };
const component = (
<ReactVisibilitySensor
onChange={(bool, shape) => {}}
onChange={(bool) => {}}
active={bool}
partialVisibility={bool}
offset={shape}
@@ -21,7 +21,15 @@ const component = (
resizeCheck={bool}
resizeDelay={num}
resizeThrottle={num}
delayedCall={bool}>
{({ isVisible: bool, visibilityRect: shape }) => <div />}
delayedCall={bool}
containment={window.document.body}
>
<div />
</ReactVisibilitySensor>
);
const componentWithFunctionAsChild = (
<ReactVisibilitySensor>
{({ isVisible, visibilityRect }) => <div />}
</ReactVisibilitySensor>
);