Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Form.getProps = form => Object.assign({},
...Object.entries(form)
.filter(([formPropKey, formProp]) => formPropKey !== 'fields')
.map(([formPropKey, formProp]) => ({
[formPropKey]: formProp instanceof Function ? formProp(form) : formProp,
})),
{
fields: Object.assign({}, ...Object.entries(form.fields).map(([fieldKey, field]) => ({
[fieldKey]: Object.assign({}, ...Object.entries(field).map(([fieldPropKey, fieldProp]) => ({
[fieldPropKey]: fieldProp instanceof Function ? fieldProp(form, fieldKey) : fieldProp,
}))),
}))),
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.