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.

componentWillMount, componentWillReceiveProps are depricated

See original GitHub issue

These 2 methods should be removed from the code.

WARN Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.
  • Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: HTML

WARN Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you’re updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: HTML

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:11

github_iconTop GitHub Comments

2reactions
bd-arccommented, Dec 29, 2019

Fix available in version 4.2.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

componentWillMount is deprecated and will be removed in the ...
componentDidMount isn't deprecated and is definitely still safe to use, so there's no need to add UNSAFE_ to that method.
Read more >
React: componentWillMount to be deprecated! - Northcoders
React: componentWillMount to be deprecated! · All three methods are frequently use incorrectly and there are better alternatives. · When asynchronous rendering is ......
Read more >
React.Component
componentDidMount () is invoked immediately after a component is mounted (inserted ... by calling setState , but this will be deprecated in a...
Read more >
React17, or how to get rid of “componentWillReceiveProps”?
As you may already know, with the release of React 16.3, some of legacy lifecycles were deprecated. One of the biggest lessons we've...
Read more >
Warning: componentWillMount is deprecated · Issue #353
Yes It's. The Warning just says that the componentWillMount is deprecated and will be removed in the next major version. Until you change...
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