Skip to content

Commit 103f34b

Browse files
committed
✏️ Only one call to FormModel
1 parent 6ccba53 commit 103f34b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

static/app/components/externalIssues/externalIssueForm.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
1+
import {useCallback, useEffect, useMemo, useState} from 'react';
22
import type {Span} from '@sentry/core';
33
import * as Sentry from '@sentry/react';
44

@@ -82,7 +82,7 @@ export default function ExternalIssueForm({
8282
Body,
8383
}: ExternalIssueFormProps) {
8484
const api = useApi({persistInFlight: true});
85-
const modelRef = useRef(new FormModel());
85+
const [model] = useState(() => new FormModel());
8686
const organization = useOrganization();
8787
const endpointString = makeIntegrationIssueConfigQueryKey({
8888
orgSlug: organization.slug,
@@ -268,12 +268,12 @@ export default function ExternalIssueForm({
268268
field,
269269
input,
270270
dynamicFieldValues,
271-
model: modelRef.current,
271+
model,
272272
successCallback: updateCache,
273273
}),
274274
});
275275
},
276-
[updateCache, dynamicFieldValues]
276+
[updateCache, dynamicFieldValues, model]
277277
);
278278

279279
const formFields = useMemo(() => {
@@ -320,10 +320,10 @@ export default function ExternalIssueForm({
320320
isLoading={isPending || isDynamicallyRefetching}
321321
formProps={{
322322
initialData,
323-
footerClass: 'modal-footer',
324323
onFieldChange,
324+
model,
325+
footerClass: 'modal-footer',
325326
submitDisabled: isPending || hasFormErrors,
326-
model: modelRef.current,
327327
submitLabel: SUBMIT_LABEL_BY_ACTION[action],
328328
apiEndpoint: endpointString,
329329
apiMethod: action === 'create' ? 'POST' : 'PUT',

0 commit comments

Comments
 (0)