Skip to content

refactor(renderer): adopt React 19 ref-as-prop + useActionState pilots - #245

Merged
h4yfans merged 2 commits into
mainfrom
debt/phase-6-u6-react-19-adoption
Apr 16, 2026
Merged

refactor(renderer): adopt React 19 ref-as-prop + useActionState pilots#245
h4yfans merged 2 commits into
mainfrom
debt/phase-6-u6-react-19-adoption

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Part of Phase 6 Tech Debt Remediation — see .claude/plans/tech-debt-remediation.md § 6.6.

Summary

Two isolated pilot migrations establishing the React 19 idiom pattern; no repo-wide sweep.

  1. components/ui/textarea.tsxforwardRefref as a prop
    • Drops React.forwardRef wrapper
    • Declares ref?: React.Ref<HTMLTextAreaElement> on the prop type
    • Plain function component; React 19 handles ref forwarding natively
  2. components/sidebar/tag-delete-dialog.tsxuseState(submitting)useActionState
    • Replaces manual setSubmitting flag with useActionState's isPending
    • Wraps the async handler in startTransition
    • Adds createLogger('TagDeleteDialog').error(...) (per CLAUDE.md convention, replacing silent finally-only swallow)
  3. docs/react-19-adoption.md documents all three React 19 idioms, pilot examples, migration guidance, and explicit "do NOT migrate" rules (crypto-adjacent, auth, Electron bootstrap, complex dialog lifecycle like TagRenameDialog).

use(promise) is documented but not piloted — the renderer does not yet use <Suspense> boundaries, so no clean 1:1 target exists. Revisit when a suspense-driven route lands.

Why

Being on React 19 is half the win; adopting idioms is the other half. Forced repo-wide migrations cause regressions; opportunistic drift-toward-19 while touching a file for other reasons is the stable pattern.

Test plan

  • CI: pnpm typecheck green (textarea + dialog re-type)
  • CI: pnpm test green (no component tests broken)
  • CI: pnpm test:e2e green (renderer render path covers both components)
  • Manual smoke: open a tag-delete dialog, confirm button state toggles on pending, cancel/escape still work

h4yfans added 2 commits April 16, 2026 18:21
Two small, isolated React 19 feature-adoption migrations to establish
the pattern. Full repo-wide migration is out of scope for this PR.

1. apps/desktop/src/renderer/src/components/ui/textarea.tsx
   forwardRef → ref as prop
   - Drops React.forwardRef wrapper
   - Declares `ref?: React.Ref<HTMLTextAreaElement>` on the prop type
   - Plain function component; React 19 handles ref forwarding natively

2. apps/desktop/src/renderer/src/components/sidebar/tag-delete-dialog.tsx
   useState(submitting) → useActionState
   - Replaces manual setSubmitting flag with useActionState's isPending
   - Wraps async handler inside startTransition for correct transition semantics
   - Adds createLogger-based error logging (per CLAUDE.md convention)

No behavior change. Both pilots keep existing a11y semantics and styling.

Plan: .claude/plans/tech-debt-remediation.md § 6.6
@h4yfans
h4yfans merged commit d2fece6 into main Apr 16, 2026
2 checks passed
h4yfans added a commit that referenced this pull request May 6, 2026
#245)

* refactor(renderer): adopt React 19 idioms in 2 pilot components

Two small, isolated React 19 feature-adoption migrations to establish
the pattern. Full repo-wide migration is out of scope for this PR.

1. apps/desktop/src/renderer/src/components/ui/textarea.tsx
   forwardRef → ref as prop
   - Drops React.forwardRef wrapper
   - Declares `ref?: React.Ref<HTMLTextAreaElement>` on the prop type
   - Plain function component; React 19 handles ref forwarding natively

2. apps/desktop/src/renderer/src/components/sidebar/tag-delete-dialog.tsx
   useState(submitting) → useActionState
   - Replaces manual setSubmitting flag with useActionState's isPending
   - Wraps async handler inside startTransition for correct transition semantics
   - Adds createLogger-based error logging (per CLAUDE.md convention)

No behavior change. Both pilots keep existing a11y semantics and styling.

Plan: .claude/plans/tech-debt-remediation.md § 6.6

* docs(react): add react-19-adoption.md covering 3 idioms + rollout
@h4yfans
h4yfans deleted the debt/phase-6-u6-react-19-adoption branch May 6, 2026 16:36
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