Mas*_*olu 8 css mobile reactjs react-router react-native

我想我添加CardsSection组件到我的Card成分,但是我不断收到此错误有关文本冲突,但我还没有使用内我的任何文字Tournament,Card或CardSection.js文件。我不明白为什么我会收到这个错误。有人能告诉我该怎么做以及为什么吗?
锦标赛.js
import React from "react";
import { View, Text, Image, ScrollView } from "react-native";
import { Card, Button, Spinner, CardSection } from "../common";
class Tournaments extends React.Component {
static navigationOptions = {
tabBarLabel: "Tournaments"
};
render() {
return (
<View style={styles.containerStyle}>
<Card>
<View style={styles.logoContainer}>
<Image
style={styles.logo}
source={require("../../Images/ShoeJackCityLogo.png")}
/>
</View>
<View style={styles.formContainer} />
</Card>
<ScrollView horizontal>
<Card>
<View style={{ flex: 1, flexDirection: "row" }}>
<CardSection>
<Image
style={styles.product}
source={require("../../Images/aj_4_toro.png")}
/>
</CardSection>
<CardSection>
<Image
style={styles.product}
source={require("../../Images/aj_4_toro.png")}
/>
</CardSection>
<CardSection>
<Image
style={styles.product}
source={require("../../Images/aj_4_toro.png")}
/>
</CardSection>
</View>
</Card>
</ScrollView>
</View>
);
}
}
const styles = {
containerStyle: {
flex: 1,
backgroundColor: "#F13C20",
paddingBottom: 20
},
logoContainer: {
alignItems: "center",
flexGrow: 1,
justifyContent: "flex-start",
paddingBottom: 15
},
logo: {
paddingTop: 15,
width: 50,
height: 50
},
product: {
width: 100,
height: 100,
paddingBottom: 15,
marginRight: 50
}
};
export default Tournaments;
Run Code Online (Sandbox Code Playgroud)
CardSection.js
import React from 'react';
import { View } from 'react-native';
const CardSection = (props) => (
<View style={styles.containerStyle}>
{props.children};
</View>
);
const styles = {
containerStyle: {
borderBottomWidth: 1,
padding: 5,
backgroundColor: 'white',
justifyContent: 'flex-start',
flexDirection: 'row',
borderColor: '#ddd',
position: 'relative'
}
};
export { CardSection };
Run Code Online (Sandbox Code Playgroud)
卡.js
import React from 'react';
import { View } from 'react-native';
const Card = (props) => (
<View style={styles.containerStyle}>
{props.children}
</View>
);
const styles = {
containerStyle: {
borderBottomWidth: 0,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 2,
elevation: 1,
marginLeft: 5,
marginRight: 5,
marginTop: 30,
}
};
export { Card };
Run Code Online (Sandbox Code Playgroud)
您在 CardSection 组件中的孩子之后连接了一个分号。这个分号被解释为文本,因为每个文本都必须在一个<Text>组件内,所以会抛出错误。
要解决问题,只需更改
const CardSection = (props) => (
<View style={styles.containerStyle}>
{props.children};
</View>
);
Run Code Online (Sandbox Code Playgroud)
到
const CardSection = (props) => (
<View style={styles.containerStyle}>
{props.children}
</View>
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9438 次 |
| 最近记录: |