Skip to content

Commit 1183f3c

Browse files
committed
Reduce time to load the overlay
1 parent 3932b30 commit 1183f3c

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

.changeset/warm-turkeys-compete.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solid-devtools/overlay": patch
3+
---
4+
5+
Reduce time to load the overlay

packages/overlay/src/index.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@ export type OverlayOptions = {
2020
}
2121

2222
export function attachDevtoolsOverlay(props?: OverlayOptions): (() => void) {
23-
let dispose: (() => void) | undefined
2423

24+
/*
25+
Only load the overlay after the page is loaded
26+
*/
27+
let show = atom(false)
2528
setTimeout(() => {
26-
s.createRoot(_dispose => {
27-
dispose = _dispose
28-
return <Overlay {...props} />
29-
})
30-
}, 500)
29+
show.set(true)
30+
})
3131

32-
return () => {
33-
dispose?.()
34-
}
32+
return s.createRoot(dispose => {
33+
s.createEffect(() => {
34+
if (show()) {
35+
<Overlay {...props} />
36+
}
37+
})
38+
return dispose
39+
})
3540
}
3641

3742
const Overlay: s.Component<OverlayOptions> = ({defaultOpen, alwaysOpen, noPadding}) => {

0 commit comments

Comments
 (0)