From dcfb3b7d37f2232e165dc660adb8599ebad867c2 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:07:01 +1000 Subject: [PATCH] Throw error on re-registering component only if in prod environment (#5990) This was causing an error when hot-reloading components, meaning that the components would not be refreshed. --- ui/v2.5/src/patch.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/v2.5/src/patch.tsx b/ui/v2.5/src/patch.tsx index 548993a07..2d1d3543e 100644 --- a/ui/v2.5/src/patch.tsx +++ b/ui/v2.5/src/patch.tsx @@ -39,7 +39,13 @@ export function RegisterComponent( ) { // register with the plugin api if (components[component]) { - throw new Error("Component " + component + " has already been registered"); + // only throw an error in production, in development we allow + // multiple registrations to allow for hot reloading of components + if (!import.meta.env.DEV) { + throw new Error( + "Component " + component + " has already been registered" + ); + } } components[component] = fn;