Skip to content

Commit

Permalink
fix: ensure array fields can render if value is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarchoudhary96 authored Oct 20, 2023
1 parent 922a839 commit 47ab3c9
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 47ab3c9

Please sign in to comment.