From 9a96e74fe1af8f17f7c7cd5a42029a71678dde6a Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 17 Dec 2024 17:13:32 +0200 Subject: [PATCH] Use defaultProps --- .../core/src/js/feedback/FeedbackForm.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/core/src/js/feedback/FeedbackForm.tsx b/packages/core/src/js/feedback/FeedbackForm.tsx index c978db83e..6508c5473 100644 --- a/packages/core/src/js/feedback/FeedbackForm.tsx +++ b/packages/core/src/js/feedback/FeedbackForm.tsx @@ -1,5 +1,5 @@ +import type { SendFeedbackParams } from '@sentry/core'; import { captureFeedback, getCurrentScope, lastEventId } from '@sentry/core'; -import type { SendFeedbackParams } from '@sentry/types'; import * as React from 'react'; import type { KeyboardTypeOptions } from 'react-native'; import { @@ -24,7 +24,7 @@ import type { FeedbackFormProps, FeedbackFormState, FeedbackFormStyles,FeedbackG * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback. */ export class FeedbackForm extends React.Component { - private _config: FeedbackFormProps; + public static defaultProps: Partial; public constructor(props: FeedbackFormProps) { super(props); @@ -36,30 +36,30 @@ export class FeedbackForm extends React.Component void = () => { const { name, email, description } = this.state; - const { onFormClose } = this._config; - const text: FeedbackTextConfiguration = this._config; + const { onFormClose } = FeedbackForm.defaultProps; + const text: FeedbackTextConfiguration = FeedbackForm.defaultProps; const trimmedName = name?.trim(); const trimmedEmail = email?.trim(); const trimmedDescription = description?.trim(); - if ((this._config.isNameRequired && !trimmedName) || (this._config.isEmailRequired && !trimmedEmail) || !trimmedDescription) { + if ((FeedbackForm.defaultProps.isNameRequired && !trimmedName) || (FeedbackForm.defaultProps.isEmailRequired && !trimmedEmail) || !trimmedDescription) { Alert.alert(text.errorTitle, text.formError); return; } - if (this._config.shouldValidateEmail && (this._config.isEmailRequired || trimmedEmail.length > 0) && !this._isValidEmail(trimmedEmail)) { + if (FeedbackForm.defaultProps.shouldValidateEmail && (FeedbackForm.defaultProps.isEmailRequired || trimmedEmail.length > 0) && !this._isValidEmail(trimmedEmail)) { Alert.alert(text.errorTitle, text.emailError); return; } @@ -84,9 +84,9 @@ export class FeedbackForm extends React.Component { onFormClose();