这节省了我很多时间:
您将要确保关闭“ JS开发模式”,否则它将在设备上缓慢运行。
这是您在Android上禁用JS开发模式的方式:
运行“ react-native run-android”后,您应“摇动”设备以显示菜单。选择“开发设置”,然后取消选中“ JS开发模式”。
之后,再次运行“ react-native run-android”,它应该具有更高的性能,至少我希望您:)
来源:https : //github.com/aksonov/react-native-router-flux/issues/199
在您的条目文件中尝试添加以下代码片段:
if (!__DEV__) {
console.log = () => {};
}
Run Code Online (Sandbox Code Playgroud)
这将允许控制台日志在开发期间工作,但当您发布到生产环境时,它只是一个空函数调用。
您正在运行什么版本的 React Native?你在什么手机上运行它?
如果你在 Android 模拟器上运行 React Native,速度会非常慢。另外,如果你打开了 chrome 调试,它会大大减慢应用程序的速度。
我在我的 Samsung Galaxy s4 设备上运行一个相当简单的 React Native 应用程序,它运行得相当快(动画也运行得相当流畅)。
我运行的一些示例代码(侧抽屉和带动画的主视图):
_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>
);
},
Run Code Online (Sandbox Code Playgroud)
这在我的设备上运行得相当快。
归档时间: |
|
查看次数: |
8140 次 |
最近记录: |