Skip to content

fix replace-string-ref to delete refs on unmount - #6

Merged
alexbit-codemod merged 2 commits into
mainfrom
fix/replace-string-ref-delete-on-unmount
Aug 8, 2026
Merged

fix replace-string-ref to delete refs on unmount#6
alexbit-codemod merged 2 commits into
mainfrom
fix/replace-string-ref-delete-on-unmount

Conversation

@alexbit-codemod

@alexbit-codemod alexbit-codemod commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Update replace-string-ref callback refs to delete this.refs… when React passes null on unmount, matching string-ref property removal semantics (aligned with codemod/codemod#1310).
  • Add a dedicated delete-ref-on-unmount fixture and update existing expected outputs; document the behavior in the package README.

Test plan

  • pnpm test in codemods/replace-string-ref (11 fixtures pass)
  • Spot-check transformed callback refs still assign on mount and delete on unmount for identifier and non-identifier ref names

Made with Cursor

alexbit-codemod and others added 2 commits August 7, 2026 17:11
Match string-ref semantics by deleting this.refs properties when callback refs receive null, instead of assigning null.

Co-authored-by: Cursor <cursoragent@cursor.com>
Accept Workflow failed / runtime javascript phrasing so CI matches codemod@latest error reporting.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexbit-codemod
alexbit-codemod requested a balanced review from Copilot August 8, 2026 00:16
@alexbit-codemod

Copy link
Copy Markdown
Contributor Author

/codex-review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates replace-string-ref to preserve string-ref cleanup semantics by deleting ref properties when React supplies null.

Changes:

  • Generate callbacks that assign refs on mount and delete them on unmount.
  • Add and update transformation fixtures.
  • Document cleanup behavior and broaden an unrelated CLI error assertion.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
codemods/replace-string-ref/scripts/codemod.ts Adds conditional ref cleanup.
codemods/replace-string-ref/README.md Documents unmount semantics.
codemods/replace-string-ref/tests/delete-ref-on-unmount/input.tsx Adds cleanup fixture input.
codemods/replace-string-ref/tests/delete-ref-on-unmount/expected.tsx Verifies generated cleanup.
codemods/replace-string-ref/tests/delete-ref-on-unmount/metrics.json Verifies fixture metrics.
codemods/replace-string-ref/tests/non-identifier-ref-name/expected.tsx Covers bracket-property cleanup.
codemods/replace-string-ref/tests/namespace-import/expected.tsx Updates namespace-import output.
codemods/replace-string-ref/tests/multiple-string-refs/expected.tsx Updates multiple-ref output.
codemods/replace-string-ref/tests/export-default-class/expected.tsx Updates exported-class output.
codemods/replace-string-ref/tests/class-component-named-import/expected.tsx Updates named-import output.
codemods/replace-string-ref/tests/class-component-default-import/expected.tsx Updates default-import output.
codemods/replace-string-ref/tests/class-component-custom-import-names/expected.tsx Updates aliased-import output.
codemods/create-element-to-jsx/scripts/error-tests.mjs Accepts another CLI runtime diagnostic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@alexbit-codemod
alexbit-codemod merged commit 867a072 into main Aug 8, 2026
3 checks passed
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.

3 participants