I am building a react native application and am trying to set the source of an image based on the contents that I am passing to the component as a prop. My code is as follows:
const nameOfComponent = props => {
return (
<View style={some style}>
<Image source={require(props.imageURL)} style={some style} />
</View>
)
}
The prop imageURL is being passed down from the parent component by:
<nameOfComponent imageURL="../dir/name.png" />
When including the code above in my project, I am met with an error saying "Invalid call at line 15: require(props.imageURL)".
Why is this happening? Thanks!
require("../dir/name.png")
– xdeepakv