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.

Usage of deprecated and unsafe methods

See original GitHub issue

Version

  • react-bootstrap-typeahead: 3.3.2
  • react, react-dom: 16.7.0

Steps to reproduce

Wrap the app in <React.StrictMode> and start it in development mode.

Repro: https://github.com/thetric/react-bootstrap-typeahead-legacy-api-repro

Expected Behavior

This library should be warning-free in React.StrictMode

Actual Behavior

React logs warnings of legacy API usage:

Deprecated findDOMNode

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

    in div (created by HintContainer(TypeaheadInputSingle))
    in HintContainer(TypeaheadInputSingle) (created by Context.Consumer)
    in Unknown (created by InputContainer(Component))
    in InputContainer(Component) (created by Typeahead)
    in div (created by Typeahead)
    in Typeahead (created by WrappedTypeahead)
    in WrappedTypeahead (created by TypeaheadContainer(WrappedTypeahead))
    in RootCloseWrapper (created by TypeaheadContainer(WrappedTypeahead))
    in TypeaheadContainer(WrappedTypeahead) (at App.js:13)
    in App (at src/index.js:9)
    in StrictMode (at src/index.js:9)

Learn more about using refs safely here:
https://fb.me/react-strict-mode-find-node

Unsafe lifecycle methods Fixed

Fixed in v4.0.0-alpha.1 pre-release. (see comment below).

Warning: Unsafe lifecycle methods were found within a strict-mode tree:
    in StrictMode (at src/index.js:9)

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: TypeaheadContainer(WrappedTypeahead)

Learn more about this warning here:
https://fb.me/react-strict-mode-warnings

Note from Update on Async Rendering:

Both the older componentWillReceiveProps and the new getDerivedStateFromProps methods add significant complexity to components. This often leads to bugs. Consider simpler alternatives to derived state to make components predictable and maintainable.

Also see You Probably Don’t Need Derived State.

In React 17 componentWillReceiveProps will be removed. (Only UNSAFE_XXX will remain.)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
MWallenbergcommented, Dec 12, 2019

This seems like a required, but breaking, change. Might I propose a new major-version of react-bootstrap-typeahead, with dropped support for react < 16.8 but this issue fixed?

2reactions
ericgiocommented, Feb 11, 2019

componentWillReceiveProps removed in v4.0.0-alpha.1 pre-release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use of Obsolete Methods | OWASP Foundation
The use of deprecated or obsolete functions may indicate neglected code. As programming languages evolve, functions occasionally become obsolete due to:.
Read more >
Deprecated and obsolete features - JavaScript - MDN Web Docs
This page lists features of JavaScript that are deprecated (that is, still available but planned for removal) and obsolete (that is, ...
Read more >
What does it mean for a method to be deprecated? [duplicate]
Deprecated methods are methods that used to be supported and safe to use, but no longer are safe to use. They can be...
Read more >
Is it wrong to use Deprecated methods or classes in Java?
The question of whether it's right or wrong to use deprecated methods will have to be examined on individual basis.
Read more >
MET02-J. Do not use deprecated or obsolete classes or ...
Never use deprecated fields, methods, or classes in new code. Java provides an @deprecated annotation to indicate the deprecation of specific fields, ...
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