place error boundaries closer to the source

This commit is contained in:
Ben Phelps 2022-10-05 13:43:22 +03:00
parent 88c774339d
commit ea96999377
6 changed files with 31 additions and 21 deletions

View file

@ -1,5 +1,7 @@
import dynamic from "next/dynamic";
import ErrorBoundary from "components/errorboundry";
const widgetMappings = {
weatherapi: dynamic(() => import("components/widgets/weather/weather")),
openweathermap: dynamic(() => import("components/widgets/openweathermap/weather")),
@ -13,7 +15,11 @@ export default function Widget({ widget }) {
const InfoWidget = widgetMappings[widget.type];
if (InfoWidget) {
return <InfoWidget options={widget.options} />;
return (
<ErrorBoundary>
<InfoWidget options={widget.options} />
</ErrorBoundary>
);
}
return (