Skip to content

Commit ca65d97

Browse files
vonovakfacebook-github-bot
authored andcommitted
fix: foreground ripple crash on api < 23 (#37901)
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](https://github.com/facebook/react-native/blob/b0485bed0945061becace5af924fa60b17ab295f/packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js#L158) I also want to point out that this PR can be closed #30466 as it's already implemented ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID] [FIXED] - foreground ripple crashed on api < 23 For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #37901 Test Plan: tested locally on [another project](react-navigation/react-navigation#11386) because I wasn't able to get RN tester running Reviewed By: rshest Differential Revision: D46747310 Pulled By: NickGerleman fbshipit-source-id: 4ee9062f821f5d629a1a0151c2fef61d836d09a4
1 parent 2ae163a commit ca65d97

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-native/Libraries/Components/Pressable/useAndroidRippleForView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function useAndroidRippleForView(
7171

7272
return {
7373
viewProps:
74-
foreground === true
74+
foreground === true && Platform.Version >= 23
7575
? {nativeForegroundAndroid: nativeRippleValue}
7676
: {nativeBackgroundAndroid: nativeRippleValue},
7777
onPressIn(event: PressEvent): void {

0 commit comments

Comments
 (0)