The Debug JS Remotely option is currently set to true in my development build. I'd like to disable this feature, but my emulator is simply to slow to do so.
Does anybody know how to disable Debug JS Remotely without tapping the button inside the react-native menu onShake? Perhaps, by hard-coding a value inside my apps iOS directory, or passing in a flag to react-native run-ios?
Here's a link to every known instance of the `isDebuggingRemotely boolean flag I'm aiming to set to false inside the react-native GitHub.
This code may work:
iOS
#import <React/RCTDevSettings.h>
rootView.bridge.devSettings.isDebuggingRemotely = NO;
Android
getReactNativeHost()
.getReactInstanceManager()
.getDevSupportManager()
.getDevSettings()
.setRemoteJSDebugEnabled(false);
Related
Is there a way to clear cache in webview for both ios and android?
I tried using #react-native-community_cookies, it works for ios, but for android Im getting this error when trying to run: A problem occurred evaluating project ':#react-native-community_cookies'. > Plugin with id 'maven' not found.
Maybe any of you have suggestions how to fix this or know some other methods?
Thanks
You can use this plugin https://www.npmjs.com/package/#react-native-community/cookies for clear cache and write below function
import CookieManager from '#react-native-community/cookies';
CookieManager.clearAll(true)
The true param means that it will clear cookies for the webkit webview (which is what this library uses)
Check out this library it does the job done.
https://github.com/react-native-cookies/cookies
import CookieManager from '#react-native-cookies/cookies';
CookieManager.clearAll(true);
I followed the official docs to enable the Hermes engine in my app but the following always returns false:
const isHermes = () => !!global.HermesInternal;
console.log('>>>>>>>>>>>>>', isHermes());
The changes I made are setting the following in android/app/build.gradle:
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
]
Then I did a clean build with:
cd android && ./gradlew clean
yarn android
But the console.log always returns false
I too got false when console.logging isHermes(). I realized it was because I was using the normal Chrome debugger(not sure of the internals of why). When I just console.logged in VSCode, I got true. There is a special way (sorry, my 'Copy link to highlight' isn't working, it's about 1/4 of the way down the page) you have to set up the Chrome debugger when you are using Hermes. There seems to be some trouble with getting it to work with newer versions of Chrome though. My plan right now to verify I'm actually using it is to compare the size of the binary before and after enabling Hermes.
I'm working on a task where I have to update a product images. Expo cache is posing a problem, when I update the product images and re-render the screen it does update my store state but doesn't show it. When I manually cleared expo cache it did work.
I have also tried using the 'Cache-Control' header, but that didn't solve the problem.
Is there a method I can call to clear expo cache ?
As far as I know the only way to clear Expo's cache is to add the -c flag to your expo start command.
Here's their page on useful commands:
expo start -c --localhost --ios
start expo server, clear cache, load only on localhost and open on iOS simulator
I don't think there's a method in their SDK that clears the cache while the app is running like you want to.
If you want to delete the cache you can use FileSystem from Expo. In that example you can delete the directory in the cache using FileSystem.deleteAsync
// Deletes whole giphy directory with all its content
export async function deleteAllGifs() {
console.log('Deleting all GIF files...');
await FileSystem.deleteAsync(gifDir);
}
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 understand what the message is about, it is caused by the long time AJAX call.
Considering this warning will not cause any serious issue for the APP, I don't want to spend much time to fix it at this moment, this warning message will show up in both simulator and cellphone while loading from development server. My question is whether the warning message will still prompt in product mode (Load from pre-bundled file)? If it will still show up, how to disable this Warning message from configuration?
Thanks.
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(...)'];
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
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.
For Remote debugger
console.ignoredYellowBox = ['Remote debugger'];
and for all warning
console.disableYellowBox = true;
I have used Phonegap several times but since the upgrade to Mavericks / Xcode5 everything has changed.
If I try to create a helloworld project, everything looks good: it compiles and launches the simulator or installs the app on my phone. The problem is if I try to add any Phonegap functionality, the it just won't work.
UPDATE: this is how I'm creating the project:
cordova create helloworld
cordova platform add ios
I have tried directly opening helloworld.xcodeproj in Xcode, using the "cordova run ios", "cordova prepare", "cordova build" commands but none of them seems to make any difference (some of these create and copy a lot of files, but there is no difference regarding the access to "device" variable)
The only way of debugging I have managed to use is to show alerts and try/catch blocks like this:
try {
alert(device);
// var text = '';
// var i = 0;
// for (var attribute in window) {
// text = text + '\n' + attribute;
// i++;
// }
// alert("total " + i + " keys: " + text);
} catch (err) {
alert(err);
}
Trying to read from "device" variable results in the following:
The text on this error suggests that one should use the following command
phonegap plugin add thePlugin
That indeed works: it adds the desired feature on the config.xml file, but the problem persits, so it does not look like an issue related to permissions. The same thing occurs when installing and trying to use other plugins, such as accelerometer or notifications.
I really liked Phonegap because it made things easier, but now it seems the opposite. One optoin is to use an older version of Phonegap and/or Xcode, but that's not what I'm looking for.
So, what is my configuration?
Mavericks 10.9.1
Xcode 5.0.2 (5A3005)
Phonegap / cordova 3.3.0
iOS 7.0.4 (iPhone 5) --> or the emulator
Any clues?
Thanks
I finally managed to solve this issue.
The solution is simple, yet it was difficult to detect.
Every time you add a plugin using the following command: cordova plugin add thePlugin you then need to run the cordova prepare command again. This is tricky, because if you take a look at the code after adding the plugin there is some setup/changes made. But these changes aren't enough, so cordova prepare might first seem redundant, but solves the issue.
So:
create the project
add as many plugins as you might use
start developing either:
(a) directly on the generated YOURAPP.xcodeproj file, and NEVER run
the cordova prepare commmand again, otherwise you will delete all your
changes
(b) work on the "general" www folder of your project and then run cordova prepare everytime you need to create a new version. Note:
you'll need to close the xcodeproj file in order to see any changes
I tend to think that alternative "(a)" should be the optimal, just make sure you don't overwrite your files or keep your files properly versioned