fix(preview): resolve ReferenceError on refreshKey initialization order

This commit is contained in:
2026-06-12 16:50:34 -07:00
parent aa780492fd
commit 87acebfab3

View File

@@ -115,6 +115,10 @@ export default function PreviewTab() {
// ── Auto-ensure: fire a background restart when the pane loads and finds
// no running dev server, but there's a previous config to restart from.
const ensureCalledRef = useRef(false);
const deviceMode = usePreviewToolbarStore((s) => s.deviceMode);
const refreshKey = usePreviewToolbarStore((s) => s.refreshKey);
const currentPath = usePreviewToolbarStore((s) => s.currentPath);
const [ensureStatus, setEnsureStatus] = useState<
"idle" | "calling" | "starting" | "no_history" | "error"
>("idle");
@@ -159,10 +163,6 @@ export default function PreviewTab() {
const bridge = usePreviewBridge();
const origin = typeof window !== "undefined" ? window.location.origin : "";
const deviceMode = usePreviewToolbarStore((s) => s.deviceMode);
const refreshKey = usePreviewToolbarStore((s) => s.refreshKey);
const currentPath = usePreviewToolbarStore((s) => s.currentPath);
const [isForceStarting, setIsForceStarting] = useState(false);
// When the user clicks the manual refresh button in the toolbar, we don't