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.
Utilização
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} />}
/>
);
}Assinaturas
(src: string | RemoteImageSource, options?: PrefetchOptions): Promise<ImageSize>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
src | string | RemoteImageSource | Sim | — |
options | PrefetchOptions | Não | — Predefinição: {} |
Devolve
Promise<ImageSize>
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.