Skip to content
Source
Sign inSign up
TanStack/devtools

fix(devtools-utils): unmount the devtools core when a Preact or React panel unmounts #533

OpenJoviDeCroock(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/533/headopened View on GitHub

Showing 5 changed files with 72 additions and 3 deletions (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/panel-unmount-cleanup.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/devtools-utils': patch
+---
+​
+Unmount the devtools core when a Preact or React panel unmounts. The panel's ref is already detached when the effect cleanup runs (React 19, Preact 11), so the core was never unmounted.
61 additions and 0 deletionspackages/devtools-utils/src/preact/panel.test.tsxAdded
View file
@@ -0,0 +1,61 @@
+/** @jsxImportSource preact */
+​
+import { render } from 'preact'
+import { act } from 'preact/test-utils'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { createPreactPanel } from './panel'
+​
+// Minimal stand-in for a class-based devtools core.
+function makeCoreClass() {
+ const coreMount = vi.fn()
+ const coreUnmount = vi.fn()
+ const construct = vi.fn<(...args: Array<unknown>) => void>()
+ class Core {
+ mount = coreMount
+ unmount = coreUnmount
+ constructor(...args: Array<unknown>) {
+ construct(...args)
+ }
+ }
+ return { Core, construct, coreMount, coreUnmount }
+}
+​