image.prefetch
Loads and decodes the image a URL or { uri, headers } names, ahead of an
Image showing it, and resolves its size in pixels. An Image of the same URL
then shows it from the cache.
Utilisation
Warm the image cache.
// Warm the image cache.
import { Image, List, image } from 'kuito';
type Show = { id: number; poster: string };
// Warm the cache for the first screen of posters before the feed shows them.
async function warm(shows: Show[]) {
await Promise.all(shows.slice(0, 6).map((show) => image.prefetch(show.poster)));
}
function Feed(props: { shows: Show[] }) {
return (
<List
data={props.shows}
renderItem={({ item }) => <Image src={item.poster} width={120} height={180} />}
/>
);
}Signatures
(src: string | RemoteImageSource, options?: PrefetchOptions): Promise<ImageSize>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
src | string | RemoteImageSource | Oui | — |
options | PrefetchOptions | Non | — Par défaut: {} |
Retourne
Promise<ImageSize>
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.