react-native
                                
                                 react-native copied to clipboard
                                
                                    react-native copied to clipboard
                            
                            
                            
                        fix: foreground ripple crash on api < 23
Summary:
The Pressable component supports the foreground option for ripple. However, using it on old android api levels (e.g. android 5) crashes with
Error while updating property
nativeForegroundAndroid' of a view managed by:
RCTView
null
No virtual method setForeground(Landroid/ graphics/drawable/Drawable;)V in class Lcom/ facebook/react/views/view/ReactViewGroup; or its super classes
TouchableNativeFeedback.js has a check to make sure this does not happen as seen here
I also want to point out that this PR can be closed https://github.com/facebook/react-native/pull/30466 as it's already implemented
Changelog:
Test Plan:
tested locally on another project because I wasn't able to get RN tester running
| Platform | Engine | Arch | Size (bytes) | Diff | 
|---|---|---|---|---|
| android | hermes | arm64-v8a | 8,757,695 | +25 | 
| android | hermes | armeabi-v7a | 8,070,268 | +32 | 
| android | hermes | x86 | 9,250,290 | +26 | 
| android | hermes | x86_64 | 9,099,434 | +29 | 
| android | jsc | arm64-v8a | 9,318,885 | +14 | 
| android | jsc | armeabi-v7a | 8,508,785 | +13 | 
| android | jsc | x86 | 9,382,367 | +4 | 
| android | jsc | x86_64 | 9,635,612 | +6 | 
Base commit: b0485bed0945061becace5af924fa60b17ab295f Branch: main
I think this works, but we could also fix on the native side so that any usage of the prop no-ops without adding a check on the JS side. https://github.com/facebook/react-native/blob/b0485bed0945061becace5af924fa60b17ab295f/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java#L201
I think this works, but we could also fix on the native side so that any usage of the prop no-ops without adding a check on the JS side. https://github.com/facebook/react-native/blob/b0485bed0945061becace5af924fa60b17ab295f/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java#L201
I can do that, but it probably shouldn't be a noop - if foreground is not supported, it should fall back to using background ripple?
Oh, yes, I missed that the JS was changing to a specific fallback behavior. JS side solution makes sense to me then.
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was successfully merged by @vonovak in ca65d97d603f0308c18bbee835b7cf6d5f76e232.
When will my fix make it into a release? | Upcoming Releases