🐛 Fix issues with updating tiles

This commit is contained in:
Meier Lukas
2023-03-30 22:54:08 +02:00
parent 525985b1dc
commit 8c59ab0846
7 changed files with 23 additions and 34 deletions

View File

@@ -16,20 +16,18 @@ interface WidgetWrapperProps {
const useWidget = <T extends IWidget<string, any>>(widget: T): T => {
const definition = Widgets[widget.type as keyof typeof Widgets];
return useMemo(() => {
const newProps = { ...widget.properties };
const newProps = { ...widget.properties };
Object.entries(definition.options).forEach(([key, option]) => {
if (newProps[key] == null) {
newProps[key] = option.defaultValue;
}
});
Object.entries(definition.options).forEach(([key, option]) => {
if (newProps[key] == null) {
newProps[key] = option.defaultValue;
}
});
return {
...widget,
properties: newProps,
};
}, [widget]);
return {
...widget,
properties: newProps,
};
};
export const WidgetWrapper = ({