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']);
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.