Skip to content

Commit 3fb5c0b

Browse files
hannojgmeta-codesync[bot]
authored andcommitted
fix(android): fix fadeDuration=0 not working w/ props 2.0 diffing (#55521)
Summary: In our app we are using the props 2.0 diffing mechanism (ie `getDiffProps` in cpp). I noticed that our `<Image source={...} fadeDuration={0} />` were still showing with the [default 300ms fade duration](https://reactnative.dev/docs/next/image#fadeduration-android). The issue is that we instantiate the `fadeDuration` in cpp with a default value of `0`: https://github.com/facebook/react-native/blob/4356259c79076fc816e516ca98678088a251bb8e/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h#L40 and then in the props diff implementation when comparing our prop value of `0` against the default, it will not be added to the final props, thus never set in the native image view: https://github.com/facebook/react-native/blob/4356259c79076fc816e516ca98678088a251bb8e/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp#L273-L275 The native image view uses a default value of `-1` so i thought to use the same here: https://github.com/facebook/react-native/blob/4356259c79076fc816e516ca98678088a251bb8e/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt#L104 Another solution could be to type the `fadeDuration` as `std::optional`, let me know what you prefer ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Image fadeDuration=0 not working with props 2.0 enabled Pull Request resolved: #55521 Test Plan: You can enable the props 2.0 feature flags in the RNTesterApp and check the image example! Reviewed By: javache, lenaic Differential Revision: D92964613 Pulled By: fabriziocucci fbshipit-source-id: 25d9b9728db20f32283aafa6890f1b2098066203
1 parent a15cff3 commit 3fb5c0b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • packages/react-native/ReactCommon/react/renderer/components/image

packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ImageProps final : public ViewProps {
3737
Float resizeMultiplier{1.f};
3838
bool shouldNotifyLoadEvents{};
3939
SharedColor overlayColor{};
40-
Float fadeDuration{};
40+
Float fadeDuration{300.f};
4141
bool progressiveRenderingEnabled{};
4242

4343
#ifdef RN_SERIALIZABLE_STATE

0 commit comments

Comments
 (0)