Skip to content

React Contributor Playbook

Scope: React viewer toolkit (@scaryterry/pdfium/react).

This project uses strict React layering to prevent race regressions and architecture drift.

  • src/react/components/** should be thin wrappers.
  • Wrapper files should export internal roots/views and avoid direct hook/model logic.
  • Keep business logic in src/react/internal/** or src/react/hooks/**.
  • src/react/internal/** and src/react/hooks/** should not import these public wrappers:
    • components/activity-bar
    • components/bookmark-panel
    • components/default-toolbar
    • components/pdf-document-view
    • components/search-panel
    • components/thumbnail-strip
  • Public entry: src/react/components/panels/<panel>.tsx (wrapper)
  • Controller/root: src/react/internal/use-<panel>-controller.ts or src/react/internal/<panel>-root-view.tsx
  • Rendering: src/react/internal/<panel>-view.tsx
  • Pure logic: src/react/internal/<panel>-model.ts / *-helpers.ts
  • Async hooks should use guard helpers from src/react/internal/async-guards.ts.
  • Stale completion must be ignored on:
    • document switch
    • page switch
    • unmount
  • Every behavior fix must include at least one test.
  • For async changes, include deterministic stale-result coverage.
  • Keep/extend contract tests:
    • test/unit/react/components/component-wrapper-contract.test.ts
    • test/unit/react/components/panels/panel-wrapper-contract.test.ts
    • test/unit/react/layer-boundary.test.ts
  • pnpm lint
  • pnpm typecheck
  • pnpm test test/unit/react
  • pnpm test:react:stable
  • pnpm test:react:memory-regression