Commit 3fb5c0b
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: 25d9b9728db20f32283aafa6890f1b20980662031 parent a15cff3 commit 3fb5c0b
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments