Skip to content

useImageResolution hook

Get the resolution of a bundle or network image.

How to use

jsx
import { useImageResolution } from 'react-native-zoom-toolkit';

// Get resolution of a bundle image
const { isFetching, resolution, error } = useImageResolution(
  require('path to your bundle image asset')
);

// Get resolution of a network image
const { isFetching, resolution, error } = useImageResolution({
  uri: 'url to some network image',
  headers: {
    'Authorization': 'some bearer token',
  }
})
  • parameter information
PropertyTypeDescription
sourceSource | numberAn url pointing to a network image and headers or a require statement to a bundle image asset.

Type Definitions

Source

PropertyTypeDescription
uristringAn url pointing to a network image.
headersRecord<string, string> | undefinedOptional headers, in case you are accesing network protected images.

FetchImageResolutionResult

PropertyTypeDescription
isFetchingbooleanWhether the hook is fetching or not.
resolutionSizeVector | undefinedWidth and height of the image.
errorError | undefinedAn error in case the image fetching fails.

Released under the MIT License.