Skip to content

Commit 366c2d0

Browse files
fix(feedback): Disable native driver for backgroundColor animation (#4794)
* fix(feedback): Disable native driver for backgroundColor animation * Add changelog * Use nativeDriver for color animations in RN >= 0.69 * Update changelog * Fix version check Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com> --------- Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>
1 parent e1e6bc7 commit 366c2d0

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
77
<!-- prettier-ignore-end -->
88
9+
## Unreleased
10+
11+
### Fixes
12+
13+
- Disable native driver for Feedback Widget `backgroundColor` animation in unsupported React Native versions ([#4794](https://github.com/getsentry/sentry-react-native/pull/4794))
14+
915
## 6.13.0
1016

1117
### Changes

packages/core/src/js/feedback/FeedbackWidgetManager.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { modalSheetContainer, modalWrapper, topSpacer } from './FeedbackWidget.s
99
import type { FeedbackWidgetStyles } from './FeedbackWidget.types';
1010
import { getFeedbackOptions } from './integration';
1111
import { lazyLoadAutoInjectFeedbackIntegration } from './lazy';
12-
import { isModalSupported } from './utils';
12+
import { isModalSupported, isNativeDriverSupportedForColorAnimations } from './utils';
1313

1414
const PULL_DOWN_CLOSE_THRESHOLD = 200;
1515
const SLIDE_ANIMATION_DURATION = 200;
1616
const BACKGROUND_ANIMATION_DURATION = 200;
1717

18+
const useNativeDriverForColorAnimations = isNativeDriverSupportedForColorAnimations();
19+
1820
class FeedbackWidgetManager {
1921
private static _isVisible = false;
2022
private static _setVisibility: (visible: boolean) => void;
@@ -124,7 +126,7 @@ class FeedbackWidgetProvider extends React.Component<FeedbackWidgetProviderProps
124126
Animated.timing(this.state.backgroundOpacity, {
125127
toValue: 1,
126128
duration: BACKGROUND_ANIMATION_DURATION,
127-
useNativeDriver: true,
129+
useNativeDriver: useNativeDriverForColorAnimations,
128130
easing: Easing.in(Easing.quad),
129131
}),
130132
Animated.timing(this.state.panY, {
@@ -206,7 +208,7 @@ class FeedbackWidgetProvider extends React.Component<FeedbackWidgetProviderProps
206208
Animated.timing(this.state.backgroundOpacity, {
207209
toValue: 0,
208210
duration: BACKGROUND_ANIMATION_DURATION,
209-
useNativeDriver: true,
211+
useNativeDriver: useNativeDriverForColorAnimations,
210212
easing: Easing.out(Easing.quad),
211213
})
212214
]).start(() => {

packages/core/src/js/feedback/utils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export function isModalSupported(): boolean {
1818
return !(isFabricEnabled() && major === 0 && minor < 71);
1919
}
2020

21+
/**
22+
* The native driver supports color animations since React Native 0.69.
23+
* ref: https://github.com/facebook/react-native/commit/201f355479cafbcece3d9eb40a52bae003da3e5c
24+
*/
25+
export function isNativeDriverSupportedForColorAnimations(): boolean {
26+
const { major, minor } = ReactNativeLibraries.ReactNativeVersion?.version || {};
27+
return major > 0 || minor >= 69;
28+
}
29+
2130
export const isValidEmail = (email: string): boolean => {
2231
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
2332
return emailRegex.test(email);

packages/core/test/feedback/FeedbackWidgetManager.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getDefaultTestClientOptions, TestClient } from '../mocks/client';
1212

1313
jest.mock('../../src/js/feedback/utils', () => ({
1414
isModalSupported: jest.fn(),
15+
isNativeDriverSupportedForColorAnimations: jest.fn().mockReturnValue(true),
1516
}));
1617

1718
const consoleWarnSpy = jest.spyOn(console, 'warn');

0 commit comments

Comments
 (0)