joshwnj / react-visibility-sensor

Sensor component for React that notifies you when it goes in or out of the window viewport.
MIT License
2.32k stars 195 forks source link

Types of property 'children' are incompatible. #138

Open suniltc opened 6 years ago

suniltc commented 6 years ago

Hi, I'm getting below error.

TS2322: Type '{ children: Element; onChange: () => (isVisible: any) => void; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
  Type '{ children: Element; onChange: () => (isVisible: any) => void; }' is not assignable to type 'Props'.
  Types of property 'children' are incompatible.
  Type 'Element' is not assignable to type '(args: { isVisible: boolean; visibilityRect?: Shape; }) => ReactNode'.
    Type 'Element' provides no match for the signature '(args: { isVisible: boolean; visibilityRect?: Shape; }): ReactNode'.

How to solve this?

OZZlE commented 6 years ago

Maybe don't be like a non technical person and specify a bit more details.... like Node verson, React version etc.. where you get the error etc

are commented 5 years ago

This is an issue with DefinitelyTyped definitions, children property is not compatible with all usages. The type should be:

{ 
    /* other props */
    children:
        | ReactNode
        | ((args: { isVisible: boolean; visibilityRect?: Shape; }) => ReactNode);
}