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.

[0.54] Warnings for soon to be deprecated lifecycle methods

See original GitHub issue

Environment

Environment: OS: macOS High Sierra 10.13.3 Node: 8.9.3 Yarn: 1.3.2 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.54.0 => 0.54.0

Expected Behavior

No warnings would appear in debugger console.

Actual Behavior

Warnings about React soon to be deprecated lifecycle methods are displayed. e.g.:

Warning: componentWillMount is deprecated and will be removed in the next major version. Use componentDidMount instead. As a temporary workaround, you can rename to UNSAFE_componentWillMount.

Please update the following components: Container, Image, ResourceSavingSceneView, TabViewPagerPan, TouchableOpacity, Transitioner, withCachedChildNavigation(TabView)

Learn more about this warning here:
https://fb.me/react-async-component-lifecycle-hooks

Steps to Reproduce

react-native run-ios

With Chrome debugger open.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:38
  • Comments:107 (42 by maintainers)

github_iconTop GitHub Comments

108reactions
nicodeslandescommented, Mar 5, 2018

For those looking for a way to remove those warnings until the React Native components are updated, you can add the following to your code (eg at the top of index.js):

import { YellowBox } from 'react-native';

YellowBox.ignoreWarnings([
  'Warning: componentWillMount is deprecated',
  'Warning: componentWillReceiveProps is deprecated',
]);

I agree that componentWillMount should be avoided completely, but until the React Native components are updated those warnings are just getting in the way.

106reactions
njwestcommented, Mar 5, 2018

To my mind, the bigger problem is not that React Native throws this warning, but that it throws six yellow boxes (in my experience at least) due to duplicate deprecation warnings for componentWillMount and componentWillReceiveProps.

This hurts the dev experience and makes debugging more time consuming, as the seconds wasted getting distracted by and dismissing/ignoring duplicate irrelevant errors start to add up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

componentWillMount is deprecated and will be removed in the ...
0 and Whenever run the apps on iOS there is found warning about deprecate the lifecycle methods. and also please update the components....
Read more >
Problematic React Lifecycle Methods are Going Away in ...
The React team has decided to deprecate some of the lifecycle methods with React 17. A recent blog post from the reactjs team...
Read more >
дэн on Twitter: "@_reznord @reactjs Please wait for official ...
17, following lifecycle methods are going to be deprecated: componentWillMount, componentWillUpdate, componentWillReceiveProps More info on ...
Read more >
find_element_by_tag_name is deprecated - You.com | The AI ...
Warnings about React soon to be deprecated lifecycle methods are displayed. e.g.: Warning: componentWillMount is deprecated and will be removed in the next ......
Read more >
React-Native Lifecycle Methods Warning - ADocLib
StrictMode currently helps with: Identifying components with unsafe lifecycles; Warning about legacy string ref API usage; Warning about deprecated ...
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