Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

componentWillReceiveProps shows deprication warning in React v16.9 #19

Open
ljmerza opened this issue Aug 12, 2019 · 6 comments
Open

componentWillReceiveProps shows deprication warning in React v16.9 #19

ljmerza opened this issue Aug 12, 2019 · 6 comments

Comments

@ljmerza
Copy link

ljmerza commented Aug 12, 2019

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

@brendangibson
Copy link

+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

@ljmerza
Copy link
Author

ljmerza commented Sep 10, 2019

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

@Sabir001
Copy link

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

@Vadorequest
Copy link

image

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

@Vadorequest
Copy link

Vadorequest commented Nov 15, 2019

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)

@taschik
Copy link

taschik commented Nov 30, 2021

Are there any updates to this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants