fix replace-string-ref to delete refs on unmount - #6
Merged
Conversation
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>
Contributor
Author
|
/codex-review |
There was a problem hiding this comment.
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.
mohebifar
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
replace-string-refcallback refs todelete this.refs…when React passesnullon unmount, matching string-ref property removal semantics (aligned with codemod/codemod#1310).delete-ref-on-unmountfixture and update existing expected outputs; document the behavior in the package README.Test plan
pnpm testincodemods/replace-string-ref(11 fixtures pass)Made with Cursor