How to disable response to your own warning message below

I am working on an adaptive IOS application, and this application sometimes triggers a warning message "setState (...) Can only update a mounted or mounted component ...", I understand that there is a message, it is caused by a long time AJAX call.

Considering that this warning will not cause serious problems for APP, I do not want to spend a lot of time to fix it at the moment, this warning will appear both in the simulator and in the mobile phone when downloading from the development server. My question is, will a warning appear in product mode (loading from a pre-packaged file)? If it still appears, how to disconnect this warning from the configuration?

Thanks.

+5
source share
4 answers

To disable only setState message

"setState (...) can only update a mounted or mounted component." selected 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 do not know which one your called, but you can change these files so as not to show a warning. If your problem is with your users, that is, in release mode, the dev flag is false, which means that no warning messages will be displayed.

To disable all warnings

To turn off warnings, just change this in 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 are using a pre-packaged file, you need to specify dev as false when linking:

 react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios 
+1
source

the best solution is to write this to your index file:

 console.disableYellowBox = true; 
+7
source

To disable only this warning message, use the following code for possible files

 console.ignoredYellowBox = ['Warning: setState(...)']; 
+1
source

To answer the question you asked, no, the warning will not appear when downloading from a pre-packaged file (for example, when testing with TestFlight).

0
source

Source: https://habr.com/ru/post/1244481/


All Articles