React Contributor Playbook
React Contributor Playbook
Section titled “React Contributor Playbook”Scope: React viewer toolkit (@scaryterry/pdfium/react).
This project uses strict React layering to prevent race regressions and architecture drift.
Required shapes
Section titled “Required shapes”Components
Section titled “Components”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/**orsrc/react/hooks/**. src/react/internal/**andsrc/react/hooks/**should not import these public wrappers:components/activity-barcomponents/bookmark-panelcomponents/default-toolbarcomponents/pdf-document-viewcomponents/search-panelcomponents/thumbnail-strip
Panels
Section titled “Panels”- Public entry:
src/react/components/panels/<panel>.tsx(wrapper) - Controller/root:
src/react/internal/use-<panel>-controller.tsorsrc/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
Test requirements
Section titled “Test requirements”- 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.tstest/unit/react/components/panels/panel-wrapper-contract.test.tstest/unit/react/layer-boundary.test.ts
Local verification before merge
Section titled “Local verification before merge”pnpm lintpnpm typecheckpnpm test test/unit/reactpnpm test:react:stablepnpm test:react:memory-regression
See also
Section titled “See also”- React Architecture - Layer boundaries and composition rules.
- Architecture Map - Concrete examples of the intended layer split.
- React Testing - Required race tests and shared teardown contract.