Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serializeNodes when props are undefined / null #118

Closed
wants to merge 1 commit into from

Conversation

tomgidden
Copy link

@tomgidden tomgidden commented Aug 20, 2020

We're getting the error

index.js:362 TypeError: Cannot convert undefined or null to object
    at keys (<anonymous>)
    at Function.keys (es5-shim.js:1312)
    at serializeComp (index.js:1111)
    at index.js:1125
    at Array.reduce (<anonymous>)
    at serializeComp (index.js:1111)
    at serializeNode (index.js:1140)
    at Object.toSerializedNode (index.js:1288)
    at index.js:1387
    at Array.map (<anonymous>)

which appears to occur when props for an element (or a node within an element) is null or undefined, rather than {}. I'm not sure exactly why this is happening at this point, but this seems to fix it.

@netlify
Copy link

netlify bot commented Aug 20, 2020

Deploy preview for craftjs ready!

Built with commit 9b93e10

https://deploy-preview-118--craftjs.netlify.app

@flavienrako
Copy link

Hi guys when can you fix it ?

@matdru
Copy link
Collaborator

matdru commented Nov 11, 2020

According to our TS interface and how craft was setup to work 'props' is not optional and should not be missing when serializing a node, and in such case i'm not sure if this PR is actually fixing the root issue here or just acting as a band-aid 🤔

@prevwong
Copy link
Owner

Like what @matdru said, this error shouldn't have occurred in the first place, which suggests an underlying problem that we are not looking at.

@tomgidden @flavienrako Does this issue this still happen in the latest version of Craft (0.1.0-beta.13)? If it does, could you share an example for us to reproduce the bug? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants