重定向失败:react-native-svg:React.createElement:类型无效
Redirection fails : react-native-svg : React.createElement: type is invalid
我正在尝试理解一个错误。当我在另一个屏幕上重定向我的第一个屏幕时,我进入了捆绑器:
"Warning: React.createElement: type is invalid -- expected a string
(for built-in components) or a class/function (for composite
components) but got: %s.%s%s, object,"
我想问题出在包 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>
);
}
}
我不明白错误是什么,你能给我任何提示,任何帮助吗?
非常感谢您的时间和解释。
似乎失败了,因为您在 SVG
标签内使用了 RN 的 Image
组件。
仅支持list, and Image
only supports those some formats like png, jpg, jpeg, bmp, gif, webp, psd
as mentioned here. To fix this, you can take a look at react-native-svg-transformer儿童,帮助您轻松导入本地svg文件。
我正在尝试理解一个错误。当我在另一个屏幕上重定向我的第一个屏幕时,我进入了捆绑器:
"Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, object,"
我想问题出在包 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>
);
}
}
我不明白错误是什么,你能给我任何提示,任何帮助吗? 非常感谢您的时间和解释。
似乎失败了,因为您在 SVG
标签内使用了 RN 的 Image
组件。
仅支持list, and Image
only supports those some formats like png, jpg, jpeg, bmp, gif, webp, psd
as mentioned here. To fix this, you can take a look at react-native-svg-transformer儿童,帮助您轻松导入本地svg文件。