【发布时间】:2020-08-18 12:37:19
【问题描述】:
我试图理解一个错误。当我将我的第一个屏幕重定向到另一个屏幕时,我会进入捆绑程序:
“警告:React.createElement:类型无效——需要一个字符串 (对于内置组件)或类/函数(对于复合 组件)但得到:%s.%s%s,对象,”
我猜问题出在 svg 包上 - 当我点击时:
<TouchableOpacity onPress={() => this.props.navigation.navigate("Distance")}>
<View style={styles.statContainer}>
<ImageBackground
source={require("../../assets/images/stats-background-1.png")}
style={styles.statImage}
>
<View style={styles.row}>
<Text style={styles.statText}>
{i18n.t("stats.action.dist")}
{"\n"}
<AnimateNumber
value={this.state.stats.total_distance}
countBy={(this.state.stats.total_distance / 50).toFixed(0)}
style={styles.statTextData}
/>{" "}
{i18n.t("stats.unit.kilometre")}
</Text>
</View>
</ImageBackground>
</View>
</TouchableOpacity>
第二屏的代码是:
export default class Stats extends React.Component {
constructor(props) {
super(props);
};
render() {
return (
<ScrollView style={styles.containerScrollNoMargins}>
<Header
backgroundImage={require("../../assets/images/bg-header.png")}
centerComponent={{
text: i18n.t("stats.title"),
style: styles.headerComponentStyle,
}}
containerStyle={styles.headerContainerStyle}
statusBarProps={{ barStyle: "light-content" }}
/>
<ImageBackground
source={require("../../assets/images/background-stats.jpg")}
style={{flex : 1 }}
imageStyle={{ resizeMode: 'stretch' }}
>
<Svg height="50%" width="50%">
<Image href={require('../../assets/images/Interface_Stat_1.svg')} />
</Svg>
</ImageBackground>
</ScrollView>
);
}
}
我不明白是什么错误,你能给我任何提示,任何帮助吗? 非常感谢您的时间和解释。
【问题讨论】:
标签: react-native svg expo react-native-svg