I am developing an app using react native, I use some code base for ios and android, the ios version run smoothly.
But the android version run very slowly. the weird thing is:
When I shake the phone, and click "Debug JS" to enable debug in chrome feature, it run faster, anyone have a clue about the reason?
Sometimes, one or more than one active console.log()
lines cause this issue.
console.log
lines should be searched and deleted if they exist.
Also in production, babel-plugin-transform-remove-console can be used to clear all console.* methods automatically.
The reason for different execution speeds of javascript code when running in debug mode and without is that when you are in debug mode, in order to enable the debugging experience React Native executes the code in the Chrome browser on your computer, and the results of the execution are bridged onto the device.
Outside of the debug mode, the code is executed in the JavaScriptCore engine on the device itself.
That said, I cannot explain why the execution is so slow on the device. Are you perhaps running on an low-powered device, or an emulator with limited allocated memory?
React Native app does run slower on Android. But the performance is not real during your development. You can build a release version to check the real performance, release version is much faster than dev version.
There are also some bad codes which can make your app slow. Like console.log()
, it does slow the app during development. Avoid unnecessary re-render the view, don't use arrow function and .bind
in render
, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With