diff --git a/.changeset/polite-donkeys-reflect.md b/.changeset/polite-donkeys-reflect.md new file mode 100644 index 0000000000..7af6e055b6 --- /dev/null +++ b/.changeset/polite-donkeys-reflect.md @@ -0,0 +1,5 @@ +--- +"@electric-sql/debug-toolbar": patch +--- + +Guard against adding toolbar to DOM twice diff --git a/components/toolbar/src/index.tsx b/components/toolbar/src/index.tsx index 4b3cbd42c9..38d25e3867 100644 --- a/components/toolbar/src/index.tsx +++ b/components/toolbar/src/index.tsx @@ -103,6 +103,13 @@ export function clientApi(registry: GlobalRegistry | Registry) { // eslint-disable-next-line @typescript-eslint/no-explicit-any export function addToolbar(electric: ElectricClient) { + if (document.getElementById(TOOLBAR_CONTAINER_ID)) { + console.warn( + '[@electric-sql/debug-toolbar] Toolbar has already been added.', + ) + return + } + const toolbarApi = clientApi(electric.registry) const containerDiv = document.createElement('div')