Skip to content

Commit

Permalink
fix: issue when props are null
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 9, 2021
1 parent 1a4cef9 commit f69d66d
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions core/core/src/controls-smart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,25 @@ interface NamedComponentControl {
control: ComponentControl | null;
}
export const controlsFromProps = (props: PropTypes): ComponentControls => {
return Object.keys(props)
.map((key: string) => {
const control = controlFromProps(key, props[key]);
if (control) {
control.defaultValue = control.value;
}
return {
name: key,
control,
};
})
.filter(p => p.control)
.reduce(
(acc: ComponentControls, prop: NamedComponentControl) => ({
...acc,
[prop.name]: prop.control as any,
}),
{},
);
return props
? Object.keys(props)
.map((key: string) => {
const control = controlFromProps(key, props[key]);
if (control) {
control.defaultValue = control.value;
}
return {
name: key,
control,
};
})
.filter(p => p.control)
.reduce(
(acc: ComponentControls, prop: NamedComponentControl) => ({
...acc,
[prop.name]: prop.control as any,
}),
{},
)
: {};
};

0 comments on commit f69d66d

Please sign in to comment.