Skip to content

Commit

Permalink
fix(app-headless-cms): remove delete callback memoization
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Dec 23, 2024
1 parent a246137 commit 3cc4b02
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ export function useBind({ Bind, field }: UseBindProps) {
if (index < 0) {
return;
}
let value = bind.value;
value = [...value.slice(0, index), ...value.slice(index + 1)];

const value = [
...bind.value.slice(0, index),
...bind.value.slice(index + 1)
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,12 @@ const Actions = ({ setHighlightIndex, bind, index }: ActionsProps) => {
[moveValueUp, index]
);

const onDelete = useCallback(
(ev: React.BaseSyntheticEvent) => {
ev.stopPropagation();
showConfirmation(() => {
bind.field.removeValue(index);
});
},
[index]
);
const onDelete = (ev: React.BaseSyntheticEvent) => {
ev.stopPropagation();
showConfirmation(() => {
bind.field.removeValue(index);
});
};

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ const Actions = ({ setHighlightIndex, bind, index }: ActionsProps) => {
[moveValueUp, index]
);

const onDelete = useCallback(
(ev: React.BaseSyntheticEvent) => {
ev.stopPropagation();
showConfirmation(() => {
bind.field.removeValue(index);
});
},
[index]
);
const onDelete = (ev: React.BaseSyntheticEvent) => {
ev.stopPropagation();
showConfirmation(() => {
bind.field.removeValue(index);
});
};

return (
<>
Expand Down

0 comments on commit 3cc4b02

Please sign in to comment.