fix(docs): stop exporting non-component values from Fast Refresh boundaries - #94
Merged
randomdevpete merged 1 commit intoAug 18, 2026
Conversation
…daries DataGridApp.tsx and Layout.tsx each mixed a React component export with plain value/function exports in the same module. @vitejs/plugin-react's Fast Refresh only preserves component state across HMR when a module exports exclusively components; any other export in the same file makes it ineligible, forcing a full reload (and, since several of these demos hold state in module-scope jotai atoms, losing that state) on every edit. DataGridApp.tsx's five helper exports (sortColumns, parseSort, stringifySort, filterWares, sortWares) had no consumers outside the file, so they're now file-private, matching the convention already used by the other demo apps (e.g. BlogRoutingApp.tsx). Layout.tsx's githubRepoUrl constant is genuinely shared (DemoPage.tsx also needs it), so it moves to a new layout/siteLinks.ts module instead. Ticket: 686
randomdevpete
deleted the
task-686-fast-refresh-constantly-breaking-on-live-edits
branch
August 18, 2026 23:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
React Fast Refresh can only fast-refresh modules where every export is a React component. When a module exports both components and plain values (functions, constants, etc.), the module becomes ineligible for fast refresh, forcing full page reloads on every edit. This also wipes module-scope Jotai state.
Two docs modules were violating this pattern:
sortColumns,parseSort,stringifySort,filterWares,sortWares) alongside the component.githubRepoUrlconstant alongside the component.Fix
githubRepoUrlto a newpackages/docs/src/layout/siteLinks.ts. Updated both internal consumers (DemoPage.tsx and Layout.tsx itself) to import from there. Removed the export from Layout.tsx.Verification
githubRepoUrlusage now points to siteLinks.Style exceptions
None.