gpt4 book ai didi

javascript - 无法将没有 YogaNode 的 child 添加到没有测量功能的 parent

转载 作者:行者123 更新时间:2023-11-29 17:43:11 30 4
gpt4 key购买 nike

我遇到过这个问题,也许你们中有人遇到过并知道解决方案?我查看了互联网并检查了我的标签,没有没有标签的文字

Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'RCTRawText [text: ;]' to a 'RCTView')
addChildAt
ReactShadowNodeImpl.java:279
addChildAt
ReactShadowNodeImpl.java:56
setChildren
UIImplementation.java:482
setChildren
UIManagerModule.java:441
invoke
Method.java
invoke
JavaMethodWrapper.java:372
invoke
JavaModuleWrapper.java:160
run
NativeRunnable.java
handleCallback
Handler.java:739
dispatchMessage
Handler.java:95
dispatchMessage
MessageQueueThreadHandler.java:29
loop
Looper.java:148
run
MessageQueueThreadImpl.java:192
run
Thread.java:818

代码:Albumlist.js这是为了显示所有专辑

import React, { Component } from 'react';
import { View } from 'react-native';
import axios from 'axios';
import AlbumDetail from './AlbumDetail.js';

class AlbumList extends Component {
state = {albums: [] } ;

componentWillMount(){
axios.get('https://rallycoding.herokuapp.com/api/music_albums')
.then(response => this.setState ({ albums : response.data }));
}


renderAlbums = () => {
return this.state.albums.map(albums =>
<AlbumDetail key = {albums.title} albums={albums}/>
);
}

render(){
console.log(this.state);
return (
<View>
{this.renderAlbums()}
</View>
);
}
}

export default AlbumList;

AlbumDetail.js这是一张 AlbumDetail 卡片

import React from 'react';
import { Text, View } from 'react-native';
import Card from './Card';
import CardSection from './CardSection';


const AlbumDetail = (props) => {
return (
<Card>
<CardSection>
<View />
<View style = {styles.headerContentStyle}>
<Text>{props.albums.title}</Text>
<Text>{props.albums.artist}</Text>
</View>;
</CardSection>
</Card>
);
};

const styles= {
headerContentStyle: {
flexDirection: 'column',
justifyContent: 'space-around'
}
};

export default AlbumDetail;

卡片.js这是样式的包装器

import React from 'react';
import { View, Platform } from 'react-native';

const Card = (props) => {
return (
<View style={styles.containerStyle}>
{props.children}
</View>
);
};

const styles = {
containerStyle:{
borderWidth: 1,
borderRadius: 2,
borderColor: '#ddd',
borderBottomWidth: 0,
...Platform.select ({
ios: {
shadowColor: '#000',
shadowOffset: {width: 0, height : 2},
shadowOpacity : 0.1,
shadowRadius: 2,
},
android: {
elevation: 1
}
}),
marginLeft: 5,
marginRight: 5,
marginTop: 10
}



};

export default Card;

CardSection.js这是一个单一的卡片部分包装器,所以它看起来更好

import React from 'react';
import { View } from 'react-native';

const CardSection = (props) => {
return (
<View style= {styles.containerStyle}>
{props.children}
</View>
);
};

const styles = {
containerStyle: {
borderBottomWidth:1,
padding: 5,
backgroundColor: '#fff',
justifyContent: 'flex-start',
flexDirection: 'row',
borderColor: '#ddd',
position: 'relative'
}
};

export default CardSection;

最佳答案

您的 AlbumDetail Card 中有错字,导致 ; 没有在 Text 标签内呈现,这导致显示错误。

<View style = {styles.headerContentStyle}>
<Text>{props.albums.title}</Text>
<Text>{props.albums.artist}</Text>
</View>; // <= here

关于javascript - 无法将没有 YogaNode 的 child 添加到没有测量功能的 parent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51802790/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com