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-codemodalexbit-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-codemodand 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 CopilotAugust 8, 2026 00:16
@alexbit-codemod

Copy link
Copy Markdown
ContributorAuthor

/codex-review

CopilotAI 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
FileDescription
codemods/replace-string-ref/scripts/codemod.tsAdds conditional ref cleanup.
codemods/replace-string-ref/README.mdDocuments unmount semantics.
codemods/replace-string-ref/tests/delete-ref-on-unmount/input.tsxAdds cleanup fixture input.
codemods/replace-string-ref/tests/delete-ref-on-unmount/expected.tsxVerifies generated cleanup.
codemods/replace-string-ref/tests/delete-ref-on-unmount/metrics.jsonVerifies fixture metrics.
codemods/replace-string-ref/tests/non-identifier-ref-name/expected.tsxCovers bracket-property cleanup.
codemods/replace-string-ref/tests/namespace-import/expected.tsxUpdates namespace-import output.
codemods/replace-string-ref/tests/multiple-string-refs/expected.tsxUpdates multiple-ref output.
codemods/replace-string-ref/tests/export-default-class/expected.tsxUpdates exported-class output.
codemods/replace-string-ref/tests/class-component-named-import/expected.tsxUpdates named-import output.
codemods/replace-string-ref/tests/class-component-default-import/expected.tsxUpdates default-import output.
codemods/replace-string-ref/tests/class-component-custom-import-names/expected.tsxUpdates aliased-import output.
codemods/create-element-to-jsx/scripts/error-tests.mjsAccepts 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 mainAug 8, 2026
3 checks passed
Sign up for freeto 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

@alexbit-codemod@mohebifar