-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Hey there!
Great library, I just have one little problem/question about this line of code: see https://github.com/glenjamin/transit-immutable-js/blob/master/index.js#L215
Is there a reason for initialising the Records there? Or rather: is there a reason for initialising them with an empty Object ({})?
In my case, I have Records with a constructor and because of the initialisation of the Record with {}, I can't use default parameters ({ meta : {} }) and need to check if my nested object structures exist everywhere (data.meta && data.meta.title || ...):
export default class StartPage extends StartPageRecord {
constructor(data = { meta : {} }, name) { // this here won't work
super({
...data,
selected : new Set(data.selected),
image : new Image(data.image),
meta : new Meta({
title : data.meta.title || data.title, // these throw errors
description : data.meta.description || data.subtitle // because data.meta is undefined
}),
socialLinks : new SocialLinks(data.socialLinks)
}, name)
}
}Metadata
Metadata
Assignees
Labels
No labels