Usage of deprecated and unsafe methods
See original GitHub issueVersion
react-bootstrap-typeahead
: 3.3.2react
,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 newgetDerivedStateFromProps
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:
- Created 5 years ago
- Reactions:6
- Comments:16 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
componentWillReceiveProps
removed in v4.0.0-alpha.1 pre-release.