Thursday, October 4, 2018

Warning: isMounted(...) is deprecated in plain Javascript Classes In React Native Solved.

When you are updating your old react native project to new updated version of react native, then you might have seen a yellow warning message box in react native application that is "Warning: isMounted(...) is deprecated in plain Javascript Classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks." You are seeing this error message because imported packages in your project, might have used deprecated method that is not compatible with latest version of react native application. So in this tutorial we will provide complete guide how to hide or ignore "Warning: isMounted(...) is deprecated in plain Javascript Classes" warning message in react native application.

The warning message should look like this :

Warning: isMounted(...) is deprecated in plain Javascript Classes In React Native Solved

Solved Warning: isMounted(...) is deprecated in plain Javascript Classes. message in react native

Step-1 : Import YellowBox component in your project.
import React, { Component } from 'react'; 
import { YellowBox } from 'react-native';

Step-2 : Now Inside your class constructor() block call the ignoreWarnings() function of YellowBox .
constructor(props) { 
   super(props); 
   YellowBox.ignoreWarnings( 
      ['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader'      
    ]); 
 }

OR
constructor(props) { 
   super(props); 
   console.disableYellowBox = true;
 }

Step-3 : Save your project and rebuild you react native application.

Hope this will resolve you issues.

No comments:

Post a Comment