Skip to content

Commit 63a1c4f

Browse files
committed
account for unstable setConfirmCallback
1 parent 25c8e3a commit 63a1c4f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

static/gsAdmin/components/forkCustomer.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Fragment, useEffect, useState} from 'react';
1+
import {Fragment, useEffect, useRef, useState} from 'react';
22

33
import SelectField from 'sentry/components/forms/fields/selectField';
44
import type {Organization} from 'sentry/types/organization';
@@ -29,6 +29,11 @@ export default function ForkCustomerAction({
2929
onConfirm,
3030
setConfirmCallback,
3131
}: Props) {
32+
// TODO: We should make sure that `setConfirmCallback` is a stable function
33+
// before passing it in here. But because it's not memoized right now, we
34+
// need to store it in a ref between renders.
35+
const onConfirmRef = useRef(setConfirmCallback);
36+
3237
const [regionUrl, setRegionUrl] = useState('');
3338
const api = useApi({persistInFlight: true});
3439
const navigate = useNavigate();
@@ -57,8 +62,8 @@ export default function ForkCustomerAction({
5762
});
5863

5964
useEffect(() => {
60-
setConfirmCallback(mutate);
61-
}, [mutate, setConfirmCallback]);
65+
onConfirmRef.current(mutate);
66+
}, [mutate]);
6267

6368
const currentRegionData = getRegionDataFromOrganization(organization);
6469
const regionChoices = getRegionChoices(currentRegionData ? [currentRegionData] : []);
@@ -76,7 +81,7 @@ export default function ForkCustomerAction({
7681
stacked
7782
required
7883
value={regionUrl}
79-
onChange={(val: any) => setRegionUrl(val)}
84+
onChange={setRegionUrl}
8085
/>
8186
</Fragment>
8287
);

0 commit comments

Comments
 (0)