Skip to content

Commit

Permalink
fix(core): ignore undefined values inside snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-thebaud committed Jan 28, 2024
1 parent 82ffde0 commit 9059f43
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/model/snapshots/takeSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export default function takeSnapshot<I extends ModelInstance>(
$exists: instance.$exists,
$raw: instance.$raw,
$loaded: { ...instance.$loaded },
$values: Object.entries(instance.$values).reduce((newValues, [key, value]) => ({
...newValues,
[key]: cloneModelValue(instance.$model, value),
}), {}),
$values: Object.entries(instance.$values).reduce((newValues, [key, value]) => {
const clonedValue = cloneModelValue(instance.$model, value);

return clonedValue !== undefined ? { ...newValues, [key]: clonedValue } : newValues;
}, {}),
};
}

0 comments on commit 9059f43

Please sign in to comment.