I\'m working on a react-native IOS app, and this app sometimes will raise a Warning message \"setState(...) Can only update a mounted or mounting component. ...\", I underst
Just to answer to question you asked, no, the warning will not show up when you load from a pre-bundled file (like when testing with TestFlight).
I edited my App.js file and added this:
console.ignoredYellowBox = ['Warning: Can only update a mounted', '-[EXCamera updateFocusDepth'];
You can provide an array of things you want to ignore. Simply provide a prefix of ones you want to ignore, no '*' or other wildcard required.
To disable only the setState message
The "setState(...) Can only update a mounted or mounting component." is thrown from 4 possible files :
- node_modules/react/dist/react-with-addons.js
- node_modules/react/dist/react.js
- node_modules/react/lib/ReactNoopUpdateQueue.js
- node_modules/react/lib/ReactUpdateQueue.js
I don't know which one triggered yours, but you can modify those files to not show the warning. If your concern is for your users, that is to say in release mode, then the dev flag is false which means that will not see any warning messages.
To disable all warnings
To disable the warnings, just change this in your AppDelegate.m :
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
to
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=false"];
If you're using the pre-bundled file you'll have to specify dev as false when bundling :
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
the better solution is to write this in your index
file:
console.disableYellowBox = true;
To disable only this warning message use the following code on possible files
console.ignoredYellowBox = ['Warning: setState(...)'];
For Remote debugger
console.ignoredYellowBox = ['Remote debugger'];
and for all warning
console.disableYellowBox = true;