返回renderRow时,图像背景组件有问题。
import back1 from '../../assets/back1.jpg';
renderRowpost = ({ item }) => {
return (
MORECONTENT....
{item.imgfondo ? //IF EXIST BACK IMAGEN
<View key={"viwid_" + item.postid} style={styles.warptextopost}>
<ImageBackground source={back1}>
<Text key={"text_id" + item.postid} style={styles.stylpublictext} >{item.posttexto}</Text>
</ImageBackground>
</View>
: //as there is no image I place the text without background
<View key={"viwid_" + item.postid} style={styles.warptextopost}>
<Text key={"text_id" + item.postid} style={styles.stylpublictext} >{item.posttexto}</Text>
</View>
}
)
}
//Where I show all the content I get from RenderrenderRowpost
<FlatList
data={this.state.datapost}
renderItem={this.renderRowpost}
keyExtractor={(item, index) => index.toString()}
/>我得到了以下错误:不变冲突: Element type无效--需要一个字符串(用于内置组件)或一个类/函数(用于复合组件),但get : undefined。您可能忘记从定义在其中的文件中导出组件,或者您可能混淆了默认的导入和命名导入。,但是如果我删除ImageBackground组件或放置一个图像组件(没有文本),如果它显示正常的内容,它只会在放置ImageBackground组件时给出错误,有任何解决方案吗?我需要在视图中放一张背景图片及其相应的文字,非常感谢..
发布于 2019-09-28 05:19:33
按以下方式加载图像
<ImageBackground source={require('../../assets/back1.jpg')}>
...
</ImageBackground>我想您不能像在导入中加载js模块那样导入图像。
https://stackoverflow.com/questions/58142781
复制相似问题