react native image file path variable

JavaScript
// Need to have all variable files already set with require 

const images = {
    profile: {
        profile: require('./profile/profile.png'),
        comments: require('./profile/comments.png'),
    },
    image1: require('./image1.jpg'),
    image2: require('./image2.jpg'),
};

return (
	<View>
  {
  	props.profile ? <Image source={images.profile.profile} /> : <Image source={images.profile.comments} />
  }
  </View>
)



Source

Also in JavaScript: