react-native - 试图将“[RCTVirtualText 507]”添加到“[RCTView 509]”)?
问题描述
我一直在为 Web 开发我的应用程序,它一直在正常工作。但是,当我在 Expo / Android 中运行相同的应用程序时,我收到了这个错误。从描述中很难知道它是关于什么的。
这是完整的错误消息:
Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a '[RCTVirtualText 507]' to a '[RCTView 509]')
你知道它可能是什么吗?
这似乎是触发它的 js 文件:
...
export class SubjectListAssignScreen extends React.Component {
state = {
subjectList: [],
subListLoading: true,
};
constructor(props) {
super(props);
};
scrollDimensions = [{
width: Math.round(Dimensions.get('window').width - 20),
maxHeight: Math.round(Dimensions.get('window').height - 200)
}];
...
_getSubjects = async(text) => {
try {
await this.setState({ subListLoading: true });
let lQueryRes = await API.graphql(graphqlOperation(cqueries.listSubjectsCustom, {}));
await console.log('==> Subjects Query');
await console.log(lQueryRes);
await this.setState({ subjectList: lQueryRes.data.listSubjects.items });
await this.setState({ subListLoading: false });
}
catch (e) {
console.log("==> DB Error");
console.log(e);
await this.setState({ subListLoading: false });
};
};
...
_subjectItems = (value) => {
console.log(value.desc);
let lnum = (typeof value["num"] !== 'undefined') ? value["num"].toString() : null;
let desc = value["desc"].toString();
let lastName = (typeof value["users"][0] !== 'undefined') ? value["users"][0]["lastname"].toString() : null;
let ltype = value["type"].toString();
return (
<DataTable.Row onPress={() => {
this.props.navigation.navigate("UserListScreen", {pnum: lnum, ptype: ltype});
}}>
<DataTable.Cell>
{this._getTypeIcon(ltype)}
</DataTable.Cell>
<DataTable.Cell>
<Text>{desc}</Text>
</DataTable.Cell>
<DataTable.Cell>
<Text>{ lastName }</Text>
</DataTable.Cell>
</DataTable.Row>
);
};
async componentDidMount() {
try {
await this._getSubjects();
}
catch (e) {
console.log("==> componentDidMount error");
console.log(e);
};
};
isCloseToBottom = ({ layoutMeasurement, contentOffset, contentSize }) => {
const paddingToBottom = 20;
return layoutMeasurement.height + contentOffset.y >=
contentSize.height - paddingToBottom;
};
fetchMore = () => {
};
render() {
let sDimensions = this.scrollDimensions;
return (
<View style={{flex:20, margin:4, flexDirection:"column", justifyContent:"flex-start"}}>
<Title style={{flex:1}}>Lista de Demandas</Title>
<SafeAreaView style={[{flex:19, }, sDimensions]}>
<ScrollView
contentContainerStyle={{}}
onScroll={({nativeEvent}) => {
if (this.isCloseToBottom(nativeEvent)) {
this.fetchMore();
}}}
>
<DataTable>
<DataTable.Header>
<DataTable.Title>Type</DataTable.Title>
<DataTable.Title>Subj</DataTable.Title>
<DataTable.Title>Resp.</DataTable.Title>
</DataTable.Header>
{ !this.state.subListLoading ?
<FlatList
data={this.state.subjectList}
renderItem={({item})=>this._subjectItems(item)}
keyExtractor={item => item.desc}
/>
:
<ActivityIndicator />
}
</DataTable>
</ScrollView>
</SafeAreaView>
</View>
)
}
}
使用 Expo 37、React Native 论文和 AWS Amplify。
解决方案
由于我很难找到哪些组件不兼容,我只是放弃了完整的开发环境,创建了一个干净的环境并再次拉取最新的提交,逐个版本检查所有组件并确保所有组件都在-g 版本。之后错误就停止了。
推荐阅读
- docker - 为什么我的 Nginx 代理成功找到我的节点网络服务器,因为我的 docker-compose 没有在网络上公开任何网络服务器端口?
- java - 在 java 中读取 2GB xml 文件时出现 OOM 错误
- javascript - 如何让我的 Discord 机器人每 10 秒左右更改一次状态?(包括“听”、“玩”、“看”等)
- angular - 具有多个组件的延迟加载功能模块在 Angular 6 中不起作用
- android - 引起:java.lang.NullPointerException:SharedPreference 错误
- c++ - DirectX 大型模型 > 64k C++
- python - 如何将变量连接到python中的路径?
- c++ - WinDbg 不显示某些小型转储文件的完整堆栈跟踪
- python - 从具有多个表的 html 中解析 1 个表
- android - Fade Video-Error while opening encoder for output stream #0:0 - 可能是不正确的参数,例如 bit_rate、rate、width 或 height