From 9d2cf42f95c86765ccf4dbf8d3cbf1619dc46dd3 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Sun, 5 May 2024 13:22:59 -0700 Subject: [PATCH] Add "Refresh Image" to RNTester Image.fadeDuration example (#44414) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44414 # Changelog: [Internal] - I noticed that "Image/Fade Duration" test in RNTester is practically useless, as at the moment one scrolls to the test, the fading is most probably had already ended. This adds a "button" to refresh the image and be able to see the fading in again and again, if desired. Reviewed By: christophpurrer Differential Revision: D56978930 fbshipit-source-id: 02873b45600ad319b0b1077467f599dc1a54bee3 --- .../js/examples/Image/ImageExample.js | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/packages/rn-tester/js/examples/Image/ImageExample.js b/packages/rn-tester/js/examples/Image/ImageExample.js index 4f18636bdba..2cd72f93e34 100644 --- a/packages/rn-tester/js/examples/Image/ImageExample.js +++ b/packages/rn-tester/js/examples/Image/ImageExample.js @@ -429,6 +429,45 @@ class LoadingIndicatorSourceExample extends React.Component< } } +type FadeDurationExampleState = {| + imageHash: number, +|}; + +type FadeDurationExampleProps = $ReadOnly<{||}>; + +class FadeDurationExample extends React.Component< + FadeDurationExampleProps, + FadeDurationExampleState, +> { + state: FadeDurationExampleState = { + imageHash: Date.now(), + }; + + reloadImage = () => { + this.setState({ + imageHash: Date.now(), + }); + }; + + render(): React.Node { + const loadingImage = { + uri: `https://www.facebook.com/ads/pics/successstories.png?hash=${this.state.imageHash}`, + }; + + return ( + + + + Refresh Image + + + + This image will fade in over the time of 1.5s. + + ); + } +} + type OnLayoutExampleState = {| width: number, height: number, @@ -1448,12 +1487,7 @@ exports.examples = [ description: ('The time (in miliseconds) that an image will fade in for when it appears (default = 300).': string), render: function (): React.Node { - return ( - <> - - This image will fade in over the time of 1.5s. - - ); + return ; }, platform: 'android', },