How can I use props with image source to create usable component in react native? How should I change my code?
CategoryBox :
class CategoryBox extends Component{
render(){
return(
<View style={{width: this.props.width, height: this.props.width/2 - 30,
borderWidth: 0.5, borderColor: '#dddddd',}}>
<View style={{ flex: 1}}>
<Image style={{ flex: 1, width: null, height: null}}
source={require(this.props.image)}
/>
</View>
<View style={styles.BoxViewTextHandle}>
<Text style={{fontSize: 10, color: '#b63838'}}>{this.props.type}</Text>
<Text style={{ fontSize: 12, fontWeight: 'bold'}}>{this.props.name}</Text>
<Text style={{ fontSize: 10}}>{this.props.price}$</Text>
<StarRating
disabled={true}
maxStars={5}
rating={this.props.rating}
starSize={10}
/>
</View>
</View>
);
}
}
export default CategoryBox;