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.

Removing usage of deprecated React lifecycle hooks

See original GitHub issue

Description: Using React >= 16.3.x in StrictMode, deprecation warnings are thrown.

Warning: Unsafe lifecycle methods were found within a strict-mode tree:
    in StrictMode (created by ReactSlickDemo)
    in ReactSlickDemo

componentWillMount: Please update the following components to use componentDidMount instead: InnerSlider, Slider

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: InnerSlider

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

Impact: Other than not corresponding to react best practices, and bloating the console with errors in dev mode, this is effectively means react-slick will break in version 17.x.

CodeSandBox reproduction

🌟 I’ve created a PR to remove usage of componentWillMount (#1443) BUT, removing componentWillReceiveProps seems much more complicated…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
akirancommented, Aug 10, 2019

Released react-slick@0.25.0 with this fix

1reaction
akirancommented, Oct 19, 2020

@maxizhukov use 27.12

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lifecycle deprecated/New Methods - React Training
This function will be called in each update life-cycle caused by changes to props (parent component re-rendering) and will be passed an object...
Read more >
Understanding React v16.4+ New Component Lifecycle ...
In React 16.3 few lifecycle methods have been deprecated. For now, these methods are prefixed with UNSAFE_ and will be fully removed in...
Read more >
Replacing Component Lifecycle Methods with React Hooks
Since other lifecycle methods will be deprecated in React 17, and, in the interim, require the use of the UNSAFE_ prefix, we will...
Read more >
React.Component
Each component has several “lifecycle methods” that you can override to run code at particular times in the process. You can use this...
Read more >
Using React's useEffect Hook with lifecycle methods
One of the main reasons that these lifecycle methods were deprecated is because when React implemented async rendering, the incorrect use of one ......
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