question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning in StrictMode

See original GitHub issue

Warning: findDOMNode is deprecated in StrictMode. ... Instead, add a ref directly to the element you want to reference. Would be a version with ref support?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
richardoptibriumcommented, Apr 9, 2020

It’s not working for me unfortunately. I’m using v4.2.1

1reaction
maslianokcommented, Apr 12, 2019

However, I hate all these warnings so in version 4.1.0 I added targetDomEl property 😃

The library doesn’t use the findDOMNode method when you pass this property.

For example:

Before (findDOMNode is used)

  render() {
    return (
      <div>
        ...
        <ReactResizeDetector handleWidth handleHeight />
      </div>
    );
  }

After (without findDOMNode)

  constructor() {
    this.parentRef = React.createRef();
  }
  render() {
    return (
      <div ref={this.parentRef}>
        ...
        <ReactResizeDetector handleWidth handleHeight targetDomEl={this.parentRef.current} />
      </div>
    );
  }

Yes, you have to add an extra prop, but this should remove the annoying warning from a console.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strict Mode - React
StrictMode currently helps with: Identifying components with unsafe lifecycles; Warning about legacy string ref API usage; Warning about deprecated findDOMNode ...
Read more >
How can I solve strict mode warning without removing strict ...
In StrictMode we can see the potential warnings. Warnings tell us to make a change in code to improve performance. Isn't it? But,...
Read more >
What is StrictMode in React? - KnowledgeHut
It's exclusively used in Development Mode to warn about legacy refs. To make it simpler to notice unanticipated side effects implemented in ...
Read more >
How to Enable React Strict Mode - Kent C. Dodds
Rendering your app in React.StrictMode will warn you when a component is using a suboptimal method or API and it will help you...
Read more >
Warning on React strictmode | General Discussion | Wijmo 5
Warning on React strictmode ... If we use React strict mode with wijmo, warnings will appear. Do you plan to change findDOMNode to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found