我无法让这个简单的 NavigatorIOS 测试工作。控制台登录 My View 触发,如果我跳过 NavigatorIOS 组件并直接渲染 MyView,我可以让它渲染。但是,当 MyView 从 NavigatorIOS 组件中的组件触发时,它不会呈现除“My NavigatorIOS 测试”之外的任何内容。
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
NavigatorIOS,
Text,
View,
} = React;
var navigation = React.createClass ({
render: function() {
return (
<NavigatorIOS
initialRoute={{
component: MyView,
title: 'My NavigatorIOS test',
passProps: { myProp: 'foo' },
}}/>
);
},
});
var MyView = React.createClass({
render: function(){
console.log('My View render triggered');
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Hello there, welcome to My View
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
AppRegistry.registerComponent('navigation', () => navigation);
最佳答案
我遇到了类似的问题。我将以下内容添加到我的样式表中:
...
wrapper: {
flex: 1,
}...
然后为 NavigatorIOS
组件赋予 wrapper
样式。这解决了问题。
关于ios - 组件不会在 NavigatorIOS 中呈现 - React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29367270/