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

findDOMNode will be deprecated #141

Open dsempel opened 6 years ago

dsempel commented 6 years ago

Starting from React 16.6 it is deprecated in StrictMode and it will be deprecated from React in the future. Here is some more information about this.

The docs state the following:

Normally you don’t need this because you can attach a ref directly to a DOM node.

However, reading through the source code I see that VisibilitySensor is not rendering any DOM nodes itself, so I'm not sure what would be the best way to attach the ref.

The warning in StrictMode:

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of VisibilitySensor which is inside StrictMode. Instead, add a ref directly to the element you want to reference.

joshwnj commented 6 years ago

Thanks for the heads up @dsempel ! Will have a think about this one

donperi commented 6 years ago

@joshwnj Hope the above PR works for you.

tanyaburlakova commented 5 years ago

@joshwnj hey!

Can you please help me, I updated my app with webpack 4 and babel 7 and react-visibility-sensor is stooped working. Do you have any idea why?

Thanks!

dancrew32 commented 5 years ago

Hey gang, any chance this will hit master? Thanks! RE: https://github.com/joshwnj/react-visibility-sensor/pull/142

RoninSTi commented 4 years ago

Any updates on #142 being merged?

alizahir23 commented 4 years ago

hey can #142 please be merged into master if its working

nigellima commented 4 years ago

Hello. Any changes this PR will be merged #142? The warning is still present once the component is used

nick-0101 commented 3 years ago

Any reasons why #142 has not been merged yet?

Issue #179 is right. This project is dead, no use waiting on something that wont be merged.

johnbonds commented 3 years ago

+1 on merging this please!

nigellima commented 3 years ago

+1 on merging this, please.

ComradeLV commented 3 years ago

+1 on merging, please!

Vir-al commented 3 years ago

+1 on merging #142, please!

sajadko commented 3 years ago

+1 on merging, please!

ZengLawrence commented 3 years ago

+1 on merging #142, please!

slavagoreev commented 3 years ago

Seems that this issue is stalling for ever

Temporal solution for you guys:

if (appSettings.isDevelopment) {
  const backup = console.error;

  console.error = function filterWarnings(msg) {
    const supressedWarnings = ['Learn more about using refs'];

    if (!supressedWarnings.some((entry) => msg.includes(entry))) {
      backup.apply(console, arguments);
    }
  };
}
Seybo commented 2 years ago

+1 on merging, please!

myadzel commented 1 year ago

+1 on merging https://github.com/joshwnj/react-visibility-sensor/pull/142, please!

ThomasDEVio commented 1 year ago

Merge it!!!

ahmadalfy commented 1 year ago

2023, requesting a merge

nathggns commented 1 year ago

Has anyone forked this project? It's not maintained anymore, so seems sensible to consider forking it to solve this particular problem.

ahmadalfy commented 1 year ago

Has anyone forked this project? It's not maintained anymore, so seems sensible to consider forking it to solve this particular problem.

I replaced it with react-waypoint. It's almost a drop-in replacement