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.

6
  • @Anil Ravsaheb Ghodake Thanks but my app is not native app...
    – MINJA KIM
    Commented Oct 3, 2019 at 4: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
    Commented Oct 3, 2019 at 6: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. Commented Oct 3, 2019 at 6: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
    Commented Oct 3, 2019 at 6:21
  • @Anil Ravsaheb Ghodake Ooops sorry that I was hasty on reading docs. i thought it is only for Native ! Thanks you!
    – MINJA KIM
    Commented Oct 3, 2019 at 6:28

2 Answers 2

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

1
  • This inspired me a lot. Currently i am also managing other projects with this :)
    – MINJA KIM
    Commented Mar 6, 2022 at 14:52
-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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.