Warning: isMounted(…) is deprecated in plain Javascript Classes

前端 未结 11 1009
庸人自扰
庸人自扰 2020-12-29 03:20

I am implementing 2 screens using react-navigation. But I got the warning below while navigating to the second page:

Warning: isMounted(...) is deprec

相关标签:
11条回答
  • 2020-12-29 03:23

    This is a problem with latest React Navigation and React Native. To silence it add:

    import { YellowBox } from 'react-native';
    YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
    

    I expect it will be fixed in React Navigation within next few weeks.

    0 讨论(0)
  • 2020-12-29 03:23

    Use this statement in index.js:

    import { YellowBox } from 'react-native';
    YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
    
    0 讨论(0)
  • 2020-12-29 03:26

    The answers above didn't work for me, but adding the following to index.js did the trick:

    console.ignoreYellowBox = ['Warning: isMounted(...) is deprecated'];
    

    Or upgrade to expo 27.0.2 which basically adds the above to Expo.js. See more information here: https://forums.expo.io/t/warnings-after-upgrade-to-expo-27/9579/10

    As some of the other answers stated, it's a react-native issue so hopefully it will be fixed soon there and then in the following version of Expo.

    0 讨论(0)
  • 2020-12-29 03:27

    This is what i did for this problem for the time being:

    step 1:Tap on the warning

    step 2: In the yellow window click on the stack trace option in top right

    step 3: Find the path where the warning has occured,ex:C:\Users\username\projectname\node_modules\react\cjs\react.development.js

    step 4: Open the path in editor

    step 5: Find the key word isMounted under the deprecated api's and delete the deprecated function and warning related under it.

    step 6: Save and reload your app!!thats it

    0 讨论(0)
  • 2020-12-29 03:31

    Ignoring this message is the wrong way for a good developer If we remove this problem then the memory leakage is decreased.

    0 讨论(0)
  • 2020-12-29 03:33

    If you are using EXPO for RN development then this issue is now fixed in expo 27.0.2.

    See https://forums.expo.io/t/warnings-after-upgrade-to-expo-27/9579/12

    0 讨论(0)
提交回复
热议问题