5

I get this warring in my react app. enter image description here

It says componentWillReceiveProps has been renamed... But I don't have "componentWillReceiveProps" in my code only effects ... Maybe it is inside in node modules.

So i trying to ignore them But i don't know how...

I used create-react-app And i am using ts-lint.

Ratan Uday Kumar
  • 5,738
  • 6
  • 35
  • 54
MINJA KIM
  • 876
  • 1
  • 8
  • 22
  • @Anil Ravsaheb Ghodake Thanks but my app is not native app... – MINJA KIM Oct 03 '19 at 04:40
  • Just out of curiosity, why would you want to disable/hide these instead of just addressing the cause of them? They appear to be mostly deprecation warnings that you should have already updated, or should update as you come across them. – Drew Reese Oct 03 '19 at 06:06
  • @MINJAKIM, I also agree with **@Drew Reese**. You can able to see this warning in development mode (debug) apk. In case of release mode you won't able to see those warnings. – Anil Ravsaheb Ghodake Oct 03 '19 at 06:20
  • 1
    @Drew Reese Yes but, it is little bit weird "componentWillReceiveProps" is deprecated which i didn't use, even if it is on node modules i can't handle all node modules. :( the warns too much hide console. I can't find easily my console info that's why i trying to hide them . – MINJA KIM Oct 03 '19 at 06:21
  • @Anil Ravsaheb Ghodake Ooops sorry that I was hasty on reading docs. i thought it is only for Native ! Thanks you! – MINJA KIM Oct 03 '19 at 06:28
  • @MINJAKIM, It's Ok. For the reference for you and others who will check this post in future I have added answer with small general example. – Anil Ravsaheb Ghodake Oct 03 '19 at 06:35

2 Answers2

2

Largely inspired from this answer

const error = console.error;
function logError(...parameters) {
    let filter = parameters.find(parameter => {
        return (
        // Filter error because XXX
        parameter.includes("Warning: %s is deprecated in StrictMode")
        // Another error to filter because of YYYY
        || parameter.includes("Warning:")
        );
    });
    if(!filter) error(...parameters);
}
console.error  = logError;

Note that this code only works for errors, but you can duplicate it for console.warn or info

You can manage this in a particular .js file, and import it in the App.js

user1864070
  • 173
  • 1
  • 10
-2

By using below code you can hide the desirable warnings

import React from 'react';
import { YellowBox } from 'react-native';
import AppNavigator from './app/main';

YellowBox.ignoreWarnings([
  'Warning: isMounted(...) is deprecated',
  'Module RCTImageLoader',
  'Class RCTCxxModule',
  'Task orphaned for request ',
  'Warning',
  'Require',
  'Missing field __typename in',
  'Node',
]);

const App = () => <AppNavigator />;
export default App;
Aurangzaib Rana
  • 4,028
  • 1
  • 14
  • 23