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

Update types in index.d.ts #195

Open hpello opened 1 year ago

hpello commented 1 year ago

Description

The current types trigger an error:

node_modules/react-visibility-sensor/index.d.ts:34:38 - error TS2694: Namespace 'React' has no exported member 'StatelessComponent'.

34   const ReactVisibilitySensor: React.StatelessComponent<Props>;
                                        ~~~~~~~~~~~~~~~~~~

Indeed, React.StatelessComponent has been removed from the react types (see https://stackoverflow.com/questions/44375759/how-should-i-declare-a-stateless-functional-component-with-typescript-in-react)

This PR fixes this error.

hpello commented 1 year ago

Hello @joshwnj! Could you take a look at this PR? 🙂 We need it to keep using react-visibility-sensor in our TS codebase.

vlapo commented 1 year ago

@joshwnj StatelessComponent was deprecated in react v17 and removed in v18. Could you please merge this change? https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/v17/index.d.ts#L537