diff --git a/.changeset/few-icons-repeat.md b/.changeset/few-icons-repeat.md new file mode 100644 index 000000000..355aa1f0f --- /dev/null +++ b/.changeset/few-icons-repeat.md @@ -0,0 +1,5 @@ +--- +'@craftjs/core': patch +--- + +Correctly serialize null props diff --git a/packages/core/src/utils/serializeNode.tsx b/packages/core/src/utils/serializeNode.tsx index 0372a43b2..fcd45c510 100644 --- a/packages/core/src/utils/serializeNode.tsx +++ b/packages/core/src/utils/serializeNode.tsx @@ -20,11 +20,13 @@ export const serializeComp = ( props = Object.keys(props).reduce((result: Record, key) => { const prop = props[key]; - if (prop === undefined || prop === null || typeof prop === 'function') { + if (prop === undefined || typeof prop === 'function') { return result; } - if (key === 'children' && typeof prop !== 'string') { + if (prop === null) { + result[key] = null; + } else if (key === 'children' && typeof prop !== 'string') { result[key] = Children.map(prop, (child) => { if (typeof child === 'string') { return child;