Skip to content

Commit

Permalink
fix: don't crash when loading external data into array field items
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Dec 14, 2023
1 parent b015ece commit d13d00b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getClassNameItem = getClassNameFactory("ArrayFieldItem", styles);
export const ArrayField = ({
field,
onChange,
value,
value: _value,
name,
label,
readOnly,
Expand All @@ -27,6 +27,8 @@ export const ArrayField = ({
}: InputProps) => {
const { state, setUi } = useAppContext();

const value: object[] = _value;

const arrayState = state.ui.arrayState[id] || {
items: Array.from(value || []).map((item, idx) => {
return {
Expand Down Expand Up @@ -159,7 +161,7 @@ export const ArrayField = ({
>
{localState.arrayState.items.map((item, i) => {
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
const data = Array.from(localState.value || [])[i] as object;
const data = Array.from(localState.value || [])[i] || {};

return (
<Draggable
Expand Down

0 comments on commit d13d00b

Please sign in to comment.