I have a Header component with a prop like that :
export default function Header({ icon }) {
Inside of it, i have an image component.
What I need to achieve is to set the image path with the prop value like this :
<Image
source={require(`../assets/${icon}.png`)}
style={{ resizeMode: "cover", height: "100%", width: "100%" }}
/>
I am passing the value like this :
<Header icon="archive" />
But when i try this whole code I get this error :
Error: components/Header.js:Invalid call at line 10: require(imagePath)