Skip to content

Commit 3cc4b02

Browse files
committed
fix(app-headless-cms): remove delete callback memoization
1 parent a246137 commit 3cc4b02

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

packages/app-headless-cms/src/admin/components/ContentEntryForm/useBind.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ export function useBind({ Bind, field }: UseBindProps) {
101101
if (index < 0) {
102102
return;
103103
}
104-
let value = bind.value;
105-
value = [...value.slice(0, index), ...value.slice(index + 1)];
104+
105+
const value = [
106+
...bind.value.slice(0, index),
107+
...bind.value.slice(index + 1)
108+
];
106109

107110
bind.onChange(value.length === 0 ? null : value);
108111

packages/app-headless-cms/src/admin/plugins/fieldRenderers/object/multipleObjects.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,12 @@ const Actions = ({ setHighlightIndex, bind, index }: ActionsProps) => {
6868
[moveValueUp, index]
6969
);
7070

71-
const onDelete = useCallback(
72-
(ev: React.BaseSyntheticEvent) => {
73-
ev.stopPropagation();
74-
showConfirmation(() => {
75-
bind.field.removeValue(index);
76-
});
77-
},
78-
[index]
79-
);
71+
const onDelete = (ev: React.BaseSyntheticEvent) => {
72+
ev.stopPropagation();
73+
showConfirmation(() => {
74+
bind.field.removeValue(index);
75+
});
76+
};
8077

8178
return (
8279
<>

packages/app-headless-cms/src/admin/plugins/fieldRenderers/object/multipleObjectsAccordion.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ const Actions = ({ setHighlightIndex, bind, index }: ActionsProps) => {
7070
[moveValueUp, index]
7171
);
7272

73-
const onDelete = useCallback(
74-
(ev: React.BaseSyntheticEvent) => {
75-
ev.stopPropagation();
76-
showConfirmation(() => {
77-
bind.field.removeValue(index);
78-
});
79-
},
80-
[index]
81-
);
73+
const onDelete = (ev: React.BaseSyntheticEvent) => {
74+
ev.stopPropagation();
75+
showConfirmation(() => {
76+
bind.field.removeValue(index);
77+
});
78+
};
8279

8380
return (
8481
<>

0 commit comments

Comments
 (0)