From bd147b41e22ba5de7c9a41e3bd10f09b7dc2f913 Mon Sep 17 00:00:00 2001 From: Davyd NRB <4661784+retyui@users.noreply.github.com> Date: Fri, 1 Mar 2024 18:27:38 +0100 Subject: [PATCH] Promote to use a Promise api instead of callbacks react-native pr: https://github.com/facebook/react-native/pull/42895 --- docs/image.md | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/docs/image.md b/docs/image.md index 84c0338e64a..d6accacf46d 100644 --- a/docs/image.md +++ b/docs/image.md @@ -464,11 +464,7 @@ Abort prefetch request. ### `getSize()` ```tsx -static getSize( - uri: string, - success: (width: number, height: number) => void, - failure?: (error: any) => void, -): any; +static getSize(uri: string): Promise<{width: number, height: number}>; ``` Retrieve the width and height (in pixels) of an image prior to displaying it. This method can fail if the image cannot be found, or fails to download. @@ -477,11 +473,9 @@ In order to retrieve the image dimensions, the image may first need to be loaded **Parameters:** -|
Name
| Type | Description | -| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- | -| uri
Required
| string | The location of the image. | -| success
Required
| function | The function that will be called if the image was successfully found and width and height retrieved. | -| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. | +|
Name
| Type | Description | +| ---------------------------------------------------- | ------ | -------------------------- | +| uri
Required
| string | The location of the image. | --- @@ -490,10 +484,8 @@ In order to retrieve the image dimensions, the image may first need to be loaded ```tsx static getSizeWithHeaders( uri: string, - headers: {[index: string]: string}, - success: (width: number, height: number) => void, - failure?: (error: any) => void, -): any; + headers: {[index: string]: string} +): Promise<{width: number, height: number}>; ``` Retrieve the width and height (in pixels) of an image prior to displaying it with the ability to provide the headers for the request. This method can fail if the image cannot be found, or fails to download. It also does not work for static image resources. @@ -502,12 +494,10 @@ In order to retrieve the image dimensions, the image may first need to be loaded **Parameters:** -|
Name
| Type | Description | -| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- | -| uri
Required
| string | The location of the image. | -| headers
Required
| object | The headers for the request. | -| success
Required
| function | The function that will be called if the image was successfully found and width and height retrieved. | -| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. | +|
Name
| Type | Description | +| -------------------------------------------------------- | ------ | ---------------------------- | +| uri
Required
| string | The location of the image. | +| headers
Required
| object | The headers for the request. | ---