Respond to native work very slowly on Android

"Very slow," I mean, it loads one transition for about 5 seconds, even though it's just an example application.

Here is the whole RN application code

Take a look at onPressFeed

+6
source share
2 answers

What version of React Native are you using? And which phone are you using?

If you run React Native on Android Emulator, it will be pretty slow. Also, if you have chrome debugging enabled, it slows down the application using LOT.

I use the fairly simple React Native app on my Samsung Galaxy s4 device and it works pretty fast (the animation works pretty smoothly).

some sample code that I run (third-party and main view with animation):

 _renderCancel: function(){ if (this.state.showView) { return ( this.props.view ); } else { return ; } }, render: function() { var menu = <Menu closeDrawer={this.closeDrawer} navigator={this.props.navigator} modifyOnClose={this.modifyOnClose} />; return ( <Drawer ref="drawer" onClose={this.onClose} type={this.state.drawerType} animation={this.state.animation} openDrawerOffset={this.state.openDrawerOffset} closedDrawerOffset={this.state.closedDrawerOffset} panOpenMask={this.state.panOpenMask} panCloseMask={this.state.panCloseMask} relativeDrag={this.state.relativeDrag} panStartCompensation={this.state.panStartCompensation} openDrawerThreshold={this.state.openDrawerThreshold} content={menu} styles={drawerStyles} disabled={this.state.disabled} tweenHandler={this.tweenHandler} tweenDuration={this.state.tweenDuration} tweenEasing={this.state.tweenEasing} acceptDoubleTap={this.state.acceptDoubleTap} acceptTap={this.state.acceptTap} acceptPan={this.state.acceptPan} changeVal={this.state.changeVal} negotiatePan={false} side={this.state.rightSide ? 'right' : 'left'} > <View> <CustomToolBar onPress={this.openDrawer}/> {this._renderCancel()} </View> </Drawer> ); }, 

This is pretty fast on my device.

+2
source

This saved me a lot of time:

  • Find your code for "console.log" and comment them out before testing.
  • Turn off JS Dev mode

You need to make sure that you turn off "JS Dev Mode", otherwise it will work slowly on the device.

Here's how you disable JS Dev Mode on Android:

After running "real-native run-android", you must "shake" your device to display the menu. Select "Dev Settings" and then uncheck "JS Dev Mode".

After that, run "run-native run-android" again, and it should be a bigger performer, at least I hope for you :)

Source: https://github.com/aksonov/react-native-router-flux/issues/199

0
source

All Articles