1.5.3 • Published 8 days ago

@candlefinance/faster-image v1.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

https://github.com/candlefinance/faster-image/assets/12258850/ede91008-4dca-417c-a2ca-4d2177066316

A performant way to render images in React Native with a focus on speed and memory usage. Powered by Nuke, the smallest and most performant image loading library for iOS and macOS and Coil on Android.

The framework is lean and compiles in under 2 seconds¹. Nuke has an automated test suite 2x the size of the codebase itself, ensuring excellent reliability. Every feature is carefully designed and optimized for performance.

Coil performs a number of optimizations including memory and disk caching, downsampling the image in memory, automatically pausing/cancelling requests, and more.

Features

  • Supports visionOS
  • Fast image loading
  • Memory and disk caching
  • Placeholder support:
  • Animated transition
  • Failure image
  • Typescript support
  • Written in Swift/Kotlin

Installation

yarn add @candlefinance/faster-image

Usage

import { FasterImageView, clearCache } from '@candlefinance/faster-image';

<FasterImageView
  style={styles.image}
  onSuccess={(event) => {
    console.log(event.nativeEvent);
  }}
  onError={(event) => console.warn(event.nativeEvent.error)}
  source={{
    transitionDuration: 0.3,
    borderRadius: 50,
    cachePolicy: 'discWithCacheControl',
    showActivityIndicator: true,
    url: 'https://picsum.photos/200/200?random=1',
  }}
/>;

// Clear memory and disk cache
await clearCache();

Props

PropTypeDefaultDescription
urlstringThe URL of the image
styleobjectThe style of the image
resizeModestringcontainThe resize mode of the image
thumbhashstringThe thumbhash of the image as a base64 encoded string to show while loading (Android not tested)
blurhashstringThe blurhash of the image to show while loading (iOS only)
showActivityIndicatorbooleanfalse (iOS only)Whether to show the UIActivityIndicatorView indicator when the image is loading
base64PlaceholderstringThe base64 encoded placeholder image to show while the image is loading
cachePolicystringmemoryThe cache policy of the image
transitionDurationnumber0.75 (iOS) Android (100)The transition duration of the image
borderRadiusnumber0border radius of image
failureImagestringIf the image fails to download this will be set (blurhash, thumbhash, base64)
progressiveLoadingEnabledbooleanfalseProgressively load images (iOS only)
onErrorfunctionThe function to call when an error occurs. The error is passed as the first argument of the function
onSuccessfunctionThe function to call when the image is successfully loaded
grayscalenumber0Filter or transformation that converts the image into shades of gray (0-1).
allowHardwarebooleantrueAllow hardware rendering (Android only)
headersRecord<string, string>undefinedPass in headers
accessibilityLabelstringundefinedaccessibility label
accessiblebooleanundefinedis accessible

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

1.5.3

8 days ago

1.5.2

23 days ago

1.5.1

25 days ago

1.5.0

29 days ago

1.4.3

2 months ago

1.4.2

2 months ago

1.4.1

2 months ago

1.3.4

2 months ago

1.3.3

2 months ago

1.3.2

2 months ago

1.3.1

2 months ago

1.3.0

2 months ago

1.2.0

6 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago