问题描述
在编写组件时,我的IOS模拟器中突然出现了一个非常奇怪的错误:无法在可用视图之外调整当前堆栈顶部
When writing a component, I suddenly got a very strange error in my IOS simulator: "cannot adjust current top of stack beyond available views"
这是我的代码:
var Badge = require('./badge');
var Separator = require('./helpers/seperator');
var View = React.View;
var StyleSheet = React.StyleSheet;
var ScrollView = React.ScrollView;
var Text = React.Text;
var Profile = React.createClass({
_getRowTitle: function (userInfo, item) {
item = item.replace('_', ' ');
return item[0] ? item[0].toUpperCase() + item.slice(1) : item;
},
render: function () {
var userInfo = this.props.userInfo;
var topicArr = ['followers', 'following', 'email', 'bio'];
var list = topicArr.map((item, index) => {
return (
<View key={index}>
<View>
<Text> {this._getRowTitle(userInfo, item)} </Text>
<Text> {userInfo[item]} </Text>
</View>
<Seperator />
</View>
);
}
});
return (
<ScrollView style={styles.container}>
<Badge userInfo={this.props.userInfo} />
{list}
</ScrollView>
);
}
});
有谁知道这个错误的来源?
Does anyone know where this error is coming from?
推荐答案
好的,事实证明,当您拼错组件名称时,会在React-Native中发生这种情况。我的导入类 Separator
应拼写 Seperator
,我的linter和构建系统没有捕获错误。显然,如果你尝试使用React-native中未定义的对象,这就是你得到的错误!
Okay, so it turns out this happens in React-Native when you misspell the component name. My imported class, Separator
should have been spelled Seperator
and my linter and the build system did not catch the error. Apparently if you try to use an object that is undefined in React-native, this is the error you get!
这篇关于IOS上的React-native:无法在可用视图之外调整当前堆栈顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!