Questions around expo-asset (useAsset, etc)

I’m reading through the documentation on expo asset, and have a few questions:

  1. If useAsset is used in a React element that is rendered 100 times, does it download the same image 100 times or is it cached internally with the same key so that it is only downloaded once per application (not once per mounting the element)? Even if the same “useAsset” hook is rendered 100 times in different elements? So say you have urls “A”, “B”, and I call useAsset([“A”, “B”]) and useAsset([“A”]). Will it only download “A” once?

  2. useAsset says that it returns an array of Assets only if it download the assets, yet each Asset has a downloadAsync function… isn’t this redundant…or is this maybe if you want to refresh the asset again?

  1. I read in the documentation

For web images, use Image.prefetch(image) . Continue referencing the image normally, e.g. with <Image source={require('path/to/image.png')} /> .

What is image in this case? Image.prefetch is supposed to accept a url, yet the “path/to/image.png” is a local image. If it’s a local image, shouldn’t it call Asset.fromModule(image).downloadAsync();?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.