`componentWillMount` warnings visible even though 'componentWillMount' is not explicitly used `componentWillMount` warnings visible even though 'componentWillMount' is not explicitly used reactjs reactjs

`componentWillMount` warnings visible even though 'componentWillMount' is not explicitly used


You're getting this warning because componentWillMount is deprecated in newer React versions. If you're not using componentWillMount anywhere then one of your libraries is and it needs to be updated.

If it makes you feel better, your production build will not show these warnings in the console.

If you are unable to update libraries for whatever reason, you can try suppressing these errors in the console by putting something like console.warn = () => {} At the top of your App component but I wouldn't recommend this since then you won't be able to use console.warn later in your code. Best to just accept them as an annoyance until you're able to update your library.


If you want to use these methods, prefix the methods with UNSAFE_ . These methods are considered “unsafe” because the React team expect code that depends on these methods to be more likely to have bugs in future versions of React. So you can suppress the warning with UNSAFE_componentWillMount.


If you want to rename all deprecated lifecycles like componentWillMount or componentWillReceiveProps to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.