react-amplitude icon indicating copy to clipboard operation
react-amplitude copied to clipboard

componentWillReceiveProps shows deprication warning in React v16.9

Open ljmerza opened this issue 4 years ago • 6 comments

Need to remove componentWillReceiveProps in react-amplitude/blob/master/src/components/Amplitude.js as this is being removed in React v17

ljmerza avatar Aug 12 '19 16:08 ljmerza

+1

Also:

react-dom.development.js:11494 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: AmplitudeProvider

brendangibson avatar Sep 10 '19 14:09 brendangibson

Looks like they've abandoned this repo. Why pay for a service that doesn't bother with updates?

ljmerza avatar Sep 10 '19 16:09 ljmerza

I have made a pull request for this. Please check #22 this PR.

Sabir001 avatar Oct 17 '19 10:10 Sabir001

image

Those logs are annoying. @ryanashcraft Would you mind taking a look at this? :) The community PR looks good.

Vadorequest avatar Nov 10 '19 18:11 Vadorequest

My personal solution for this kind of things:

ignoreNoisyWarningsHacks.ts

// @ts-ignore
// eslint-disable-next-line no-console
const originalError = console.error;

// eslint-disable-next-line no-console
console.error = (...args): void => {
  if (/Warning.*Function components cannot be given refs/.test(args[0])) {
    // HACK: Muting error, fix as soon as https://github.com/zeit/next.js/issues/7915 gets resolved
    return;
  }
  originalError.call(console, ...args);
};

// eslint-disable-next-line no-console
console.warn = (...args): void => {
  if (/Warning.*componentWillMount has been renamed, and is not recommended for use/.test(args[0])) {
    // HACK: Muting warning, fix as soon as https://github.com/amplitude/react-amplitude/issues/19 gets resolved
    return;
  } else if (/Warning.*componentWillReceiveProps has been renamed, and is not recommended for use/.test(args[0])) {
    // HACK: Muting warning, fix as soon as https://github.com/amplitude/react-amplitude/issues/19 gets resolved
    return;
  } else if (/Warning.*componentWillMount has been renamed, and is not recommended for use/.test(args[0])) {
    // HACK: Muting warning, fix as soon as https://github.com/amplitude/react-amplitude/issues/19 gets resolved
    return;
  }
  originalError.call(console, ...args);
};


Import that file in your main loader (_app.ts with Next.js for instance)

Vadorequest avatar Nov 15 '19 17:11 Vadorequest

Are there any updates to this?

taschik avatar Nov 30 '21 19:11 taschik