Skip to content

Commit bfd4970

Browse files
Diogo Francothebuilder
authored andcommitted
Make children optional, correctness changes
The children can also be any ReactNode in React 16, as opposed to only JSX.Element. Even in React 15, the current definitions exclude `string` and `number`. `children` is optional, especially when `render` is provided. The `onChange` is passed through to the top level element so if the `tag` happens to be one with an `onChange` event, the `onChange` callback may be called with `React.FormEvent`.
1 parent ccebaf2 commit bfd4970

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
declare module 'react-intersection-observer' {
2-
import * as React from 'react';
2+
import React = require('react');
33

4-
export type IntersectionObserverProps = {
4+
export interface IntersectionObserverProps {
55
/** Children should be either a function or a node */
6-
children: JSX.Element | null | ((inView: boolean) => JSX.Element | null);
6+
children?: React.ReactNode | ((inView: boolean) => React.ReactNode);
77

88
/**
99
* The `HTMLElement` that is used as the viewport for checking visibility of
@@ -47,10 +47,10 @@ declare module 'react-intersection-observer' {
4747
triggerOnce?: boolean;
4848

4949
/** Call this function whenever the in view state changes */
50-
onChange?(inView: boolean): void;
50+
onChange?(inView: boolean|React.FormEvent<HTMLElement>): void;
5151

5252
/** Use `render` method to only render content when inView */
53-
render?(): JSX.Element | null;
53+
render?(): React.ReactNode;
5454
};
5555

5656
export default class IntersectionObserver extends React.Component<

0 commit comments

Comments
 (0)