我想知道为什么react-native build在发布方案中失败并且在调试方案中工作正常?
我正在使用react-native-side-menu
和react-native-navbar
。这是代码。
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Navigator,
ScrollView,
TouchableHighlight,
AlertIOS,
} = React;
var Fluxxor = require('fluxxor');
var flux = require('./flux');
var SideMenu = require('react-native-side-menu');
var MainStyles = require('./styles/main');
var NavigationBarView = React.createClass({
render: function() {
return (
<View>
<Text style={{ fontSize: 36 }}>Hello World</Text>
<Text style={{ fontSize: 36 }}>Hello World</Text>
<Text style={{ fontSize: 36 }}>Hello World</Text>
<Text style={{ fontSize: 36 }}>Hello World</Text>
</View>
);
}
});
var Menu = React.createClass({
about: function() {
this.props.menuActions.close();
},
render: function() {
return (
<View>
<Text>Menu</Text>
<Text onPress={this.about}>About</Text>
</View>
);
}
});
// Navigation with Content View
var Docit = React.createClass({
renderScene: function(route, navigator) {
var Component = route.component;
var navBar = route.navigationBar;
if (navBar) {
navBar = React.addons.cloneWithProps(navBar, {
navigator: navigator,
route: route
});
}
var menu = <Menu/>;
return (
<SideMenu menu={menu} touchToClose={true} animation='spring' onChange={(isOpen) => { console.log('isOpen: ',isOpen); } }>
<View style={MainStyles.navigator}>
{navBar}
<View style={MainStyles.container}>
<Component menu={menu} navigator={navigator} route={route} flux={flux} {...route.passProps} />
</View>
</View>
</SideMenu>
);
},
render: function() {
return (
<Navigator
style={MainStyles.navigator}
renderScene={this.renderScene}
initialRoute={{
component: NavigationBarView,
}}
configureScene={() => {
return Navigator.SceneConfigs.FloatFromRight;
}}
/>
);
}
});
AppRegistry.registerComponent('Docit', () => Docit);
代码也使用main.js
模块,它只是基本的,你可以摆脱它。正如您在Navigator
中可以看出的那样,当前逻辑将sidemenu
包裹在renderScene
中。我不知道为什么它在release
版本上显示空白屏幕。它在debug
方案中运行良好。