3

I am getting this warning:

Warning: isMounted(...) is deprecated in plain JavaScript React classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.

How do I fix the warning? I don't want to hide it like this:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module 
RCTImageLoader']);
Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
  • It is better to provide message as text [instead of an image](http://idownvotedbecau.se/imageofanexception/). – Alexander Jun 11 '18 at 14:17
  • Also note that a simple Google search for "react native isMounted site:stackoverflow.com" brought up dozens of similar results. Did you look into these before posting this? – akraf Jun 11 '18 at 15:36
  • 1
    Possible duplicate of [Warning: isMounted(...) is deprecated in plain Javascript Classes](https://stackoverflow.com/questions/49789150/warning-ismounted-is-deprecated-in-plain-javascript-classes) – Bruno Mazzardo Jun 11 '18 at 15:46

1 Answers1

2

All of the comments show you how to hide it, but not how to resolve it since the false positive has been fixed in React Native.

I was using the variable name isMounted in my React Native code, which was a custom instance variable on the class. However, this conflicted with a deprecated variable isMounted which is innately on Component classes - hence the warning.

To solve this, I simply renamed my isMounted variable name to mounted.

Big Money
  • 9,139
  • 6
  • 26
  • 37