fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.58k stars 692 forks source link

remove soon-to-be-deprecated react lifecycle functions #323

Closed iambumblehead closed 5 years ago

iambumblehead commented 5 years ago

Do you want to request a feature or report a bug?

Both. When using inferno with the latest version of redux and toastify, this warning is shown in the console,

Warning: Unsafe legacy lifecycles will not be called for components using new component APIs.
      TransitionGroup contains the following legacy lifecycles:
      componentWillMount
componentWillReceiveProps
      The above lifecycles should be removed.

Those functions will be deprecated in future version of react, and inferno renders a big red warning message when it discovers them in react-toastify.

alanlima commented 5 years ago

Hi @iambumblehead, how are you?

react-toastify doesn't use those API's so the problem is not here.

Checking the library react-transition-group, it stopped to use componentWillMount and componentWillReceiveProps on v2.4.0 which is the minimal dependency for react-toastify:

https://github.com/fkhadra/react-toastify/blob/8fc64cbe3ba4c16cda137a61358e2e111bc2658f/package.json#L50-L54

The problem might be with Inferno's render.


It is quite extra info for this issue but:

Checking the source code for react-transition-group on node_modules the library is compiled to a version that is using componentWillMount (probably for compatibility) and some flags are set to suppress warnings (which react render interprets that but Inferno doesn't)

  // React may warn about cWM/cWRP/cWU methods being deprecated.
  // Add a flag to suppress these warnings for this special case.
  componentWillMount.__suppressDeprecationWarning = true;
  componentWillReceiveProps.__suppressDeprecationWarning = true;
  componentWillUpdate.__suppressDeprecationWarning = true;

You can check this on node_modules/react-transition-group/dist/react-transition-group.js

Hopefully, it might help you in some way. ;)

iambumblehead commented 5 years ago

@alanlima thank you so much for spending the time to make this nice response :)

alanlima commented 5 years ago

@iambumblehead No worries, happy to help 🤗

fkhadra commented 5 years ago

@alanlima thanks for answering !