Skip to content

Commit

Permalink
fix: use empty array when arrayfield value is undefined when creating…
Browse files Browse the repository at this point in the history
… new array
  • Loading branch information
sagarchoudhary96 committed Oct 19, 2023
1 parent 922a839 commit b32fb4e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ArrayField = ({
const { state, setUi } = useAppContext();

const arrayState: ArrayState = state.ui.arrayState[arrayFieldId] || {
items: Array.from(value).map<ItemWithId>((v) => ({
items: Array.from(value || []).map<ItemWithId>((v) => ({
_arrayId: generateId("ArrayItem"),
data: v,
})),
Expand All @@ -54,7 +54,7 @@ export const ArrayField = ({

// Create a mirror of value with IDs added for drag and drop
useEffect(() => {
const newItems = Array.from(value).map((item, idx) => ({
const newItems = Array.from(value || []).map((item, idx) => ({
_arrayId: arrayState.items[idx]?._arrayId || generateId("ArrayItem"),
data: item,
}));
Expand Down

0 comments on commit b32fb4e

Please sign in to comment.