joshwnj / react-visibility-sensor

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

onChange not firing in latest versions #129

Closed kroney closed 6 years ago

kroney commented 6 years ago

Hey I tried to add the VisibilitySensor to my component but found out that in the latest version the onChange event is not firing. In Version 3.11.1 it still works fine. Were there any changes to the API that are not yet documented, or is this a bug?

Templaris commented 6 years ago

I am confirming this bug in my project. I had to force to use version 3.11. Later versions contains bug described above.

ericf89 commented 6 years ago

Seems to stick when devtools are open, not sure if that's a feature or not. :D

joshwnj commented 6 years ago

@kroney @Templaris @ericf89 thanks for reporting. Can you please confirm the version where the bug was seen? Also the version of react being used?

Also, if you take a look at this example, are you able to modify it in some way that reproduces the bug? https://codesandbox.io/s/p73kyx9zpm

ericf89 commented 6 years ago

Hmm. I tried to repo and couldn't. Might have just been due to my initial misunderstanding of how the sensor worked. I didn't realize it actually needed to wrap something for things to update appropriately.

joshwnj commented 6 years ago

Cool, thanks - I'll close this for now but we can reopen if we get a reproducible case.