Skip to content

Migrate to React 19, Typescript, Vite, and Vitest#5

Open
mrecachinas wants to merge 8 commits intospectriclabs:mainfrom
mrecachinas:migrate-react-19
Open

Migrate to React 19, Typescript, Vite, and Vitest#5
mrecachinas wants to merge 8 commits intospectriclabs:mainfrom
mrecachinas:migrate-react-19

Conversation

@mrecachinas
Copy link

@mrecachinas mrecachinas commented Mar 12, 2026

This PR migrates React-SigPlot to React 19, Typescript, Vite, and Vitest. This also converts all legacy classes to functional components, while maintaining the same API with one exception.

One breaking change: Layer was exported in the old version as an abstract base class users could extend. Since we replaced class inheritance with hooks, there's no Layer class anymore. Anyone who was doing import { Layer } from 'react-sigplot' and extending it would break.

The new equivalents are usePlot() and SigPlotContext -- which are more idiomatic for custom layers in React 19. Since this is a major version bump (0.x → 1.0), the Layer removal is acceptable, but we should document it.

mrecachinas and others added 8 commits March 11, 2026 20:34
- Convert all class components to functional components with hooks
- Replace legacy Context API (childContextTypes) with React.createContext + usePlot hook
- Replace UNSAFE_componentWillReceiveProps with useEffect + useRef previous-props pattern
- Replace Layer base class inheritance with shared usePlot() hook
- Convert JavaScript to TypeScript with sigplot type declarations
- Replace webpack with Vite (library mode, ESM + UMD output)
- Replace Jest + Enzyme with Vitest + @testing-library/react
- Add vitest-canvas-mock with measureText fix for sigplot compatibility
- Update peer dependencies to React ^19.0.0
- Export SigPlotContext and usePlot hook for custom layer development
- Bump version to 1.0.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run 'npm run dev' and open http://localhost:5173 to see the example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add Plot cleanup on unmount (SigPlot.tsx) — removes injected canvases
  and nulls refs/state to prevent memory leaks and Strict Mode issues
- Fix multi-prop change drop in all layer update effects — use
  independent if blocks instead of if/else if chain so simultaneous
  prop changes are all processed
- Fix WPipeLayer: add wsurl default, remove non-null assertions,
  remove unused overrides prop from interface
- Guard change_settings calls against undefined props in all layers
- Fix PipeLayer initial mount to handle ArrayBuffer data (not just arrays)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- BlueLayer: 5 tests covering mount, reload, headermod, no-op, unmount
- Plugin: 2 tests covering add on mount, remove on unmount
- src/ coverage now at ~80% (all public API components 94-100%)
- Install @vitest/coverage-v8 for coverage reporting

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mock overlay_href in all HrefLayer and SigPlot HrefLayer tests to
prevent sigplot from firing real XHR requests that fail in jsdom
with a DataView bounds error when parsing bluefile responses.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add --no-warnings to vitest fork execArgv to suppress the harmless
Node 25 localstorage-file warning emitted by jsdom workers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mrecachinas mrecachinas changed the title Migrate react 19 Migrate to React 19, Typescript, Vite, and Vitest Mar 12, 2026
@mrecachinas mrecachinas marked this pull request as ready for review March 12, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant