react-amplitude
react-amplitude copied to clipboard
componentWillReceiveProps shows deprication warning in React v16.9
Need to remove componentWillReceiveProps
in react-amplitude/blob/master/src/components/Amplitude.js
as this is being removed in React v17
+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
Looks like they've abandoned this repo. Why pay for a service that doesn't bother with updates?
I have made a pull request for this. Please check #22 this PR.
Those logs are annoying. @ryanashcraft Would you mind taking a look at this? :) The community PR looks good.
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)
Are there any updates to this?