There are two ways to require
an image for an Image
component in React Native.
// 1. inline `require` (triggered when using)
const IconView = () =>
<Image source={require('./img/favicon.png')} />
// 2. define a variable for cache (triggered when loading)
const imageSource = require('./img/favicon.png')
const IconView = () =>
<Image source={imageSource} />
require
be released?The call to require
doesn't do much - it returns an ID which was registered by the RN packager and assigned to this image. The actual URL is resolved from the ID when the image component needs to render.
On the native side, the image is loaded from the URL, and even at this point it only takes a small amount of memory for the image object representation. Only when the image is actually drawn as a native texture it gets inflated (decompressed) and loaded in full into the memory (unless, of course, the image was already cached).
So to answer your questions:
Note: some of the above info is from an iOS perspective, but it should work close enough on Android as well.