-
Notifications
You must be signed in to change notification settings - Fork 24k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Update
Image.getSize/getSizeWithHeaders
methods to return…
… a promise (#42895) Summary: `Image.getSize/getSizeWithHeaders` are still working in old fashioned "callback" way ```tsx Image.getSize(uri, function success(width,height) { }, function failure(){ } ); // undefined Image.getSizeWithHeaders(uri, headers, function success(width,height) { }, function failure(){ } ); // undefined ``` But in 2024 more developers prefer use async/await syntax for asynchronous operations So, in this PR I added support for Promise API with **backward compatibility**, modern way: ```tsx Image.getSize(uri).then(({width,height}) => { }); // Promise Image.getSizeWithHeaders(uri, headers).then(({width,height}) => { }); // Promise ``` bypass-github-export-checks ## Changelog: [GENERAL] [ADDED] - `Image.getSize/getSizeWithHeaders` method returns a promise if you don't pass a `success` callback Pull Request resolved: #42895 Test Plan: 1. ts: New test cases added in typescript tests 2. runtime: you can create a new project and put code from this PR into the next files a. `node_modules/react-native/Libraries/Image/Image.android.js` b. `node_modules/react-native/Libraries/Image/Image.ios.js` Reviewed By: javache Differential Revision: D53919431 Pulled By: cipolleschi fbshipit-source-id: 508b201e17e0ffda2e67aa5292bf9906b88d09c5
- Loading branch information
1 parent
489df72
commit 2c1bcba
Showing
7 changed files
with
74 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters