Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Print an error when the modal is not supported
  • Loading branch information
antonis committed Jan 27, 2025
commit 84108f151b0e4dcfe8c24ca402f98cc09086020a
7 changes: 7 additions & 0 deletions packages/core/src/js/feedback/FeedbackFormManager.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { logger } from '@sentry/core';
import * as React from 'react';
import { Modal, View } from 'react-native';

import { FeedbackForm } from './FeedbackForm';
import defaultStyles from './FeedbackForm.styles';
import type { FeedbackFormStyles } from './FeedbackForm.types';
import { isModalSupported } from './utils';

class FeedbackFormManager {
private static _isVisible = false;
Expand Down Expand Up @@ -51,6 +53,11 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
* Renders the feedback form modal.
*/
public render(): React.ReactNode {
if (!isModalSupported()) {
logger.error('FeedbackForm Modal is not supported in React Native < 0.71 with Fabric renderer.');
return <>{this.props.children}</>;
}

const { isVisible } = this.state;
const styles: FeedbackFormStyles = { ...defaultStyles, ...this.props.styles };

Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/js/feedback/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import { isFabricEnabled } from '../utils/environment';
import { ReactNativeLibraries } from './../utils/rnlibraries';

/**
* Modal is not supported in React Native < 0.71 with Fabric renderer.
* ref: https://github.com/facebook/react-native/issues/33652
*/
export function isModalSupported(): boolean {
const rnVersion = ReactNativeLibraries.ReactNativeVersion?.version;
if (isFabricEnabled() && rnVersion && rnVersion.major === 0 && rnVersion.minor < 71) {
return false;
}
return true;
}

export const isValidEmail = (email: string): boolean => {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return emailRegex.test(email);
Expand Down
Loading