Repository navigation
feat: v2.0.0 — React 19 only, drop React 15.6 build and forwardRef - #128
Conversation
BREAKING CHANGE: requires React 19 or later. - Remove the legacy src/react-15.6 class component and its componentDidUpdate custom-property fallback for react/react#6411 (dead code since React 16). - Flatten src/react-latest into src/index.tsx; the default and named exports are now the same component. - Drop the forwardRef wrapper — React 19 passes ref as a regular prop. - Narrow peerDependencies to react >=19.0.0 and bump @types/react to ^19. - Exclude test files from the published build instead of a stale __tests__ glob. - Add MIGRATION.md and a README migration section. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
README’s new Requirements wording is currently misleading about forwardRef vs React 19’s ref-as-prop behavior, and should be corrected before release.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR bumps react-aspect-ratio to 2.0.0 by making React 19+ the only supported peer, removing the legacy React 15.6 implementation path, and simplifying the public entry point so default and named exports are identical.
Changes:
- Drop React 15.6 fallback build and remove the
forwardRefwrapper in favor of React 19’sref-as-prop behavior. - Flatten the source entry point to
src/index.tsxand remove the oldsrc/index.tsshim andsrc/react-latest/entry. - Tighten publish/build output by excluding test files correctly and update documentation with a migration guide.
File summaries
| File | Description |
|---|---|
| tsconfig.publish.json | Excludes test files and stories from the publish TS build. |
| src/types.ts | Switches to explicit ComponentProps import for Props. |
| src/react-latest/index.tsx | Removes the previous forwardRef-based implementation. |
| src/react-latest/snapshots/index.test.tsx.snap | Removes snapshot from the old react-latest test location. |
| src/react-15.6/index.tsx | Removes legacy React 15.6 class-component implementation. |
| src/react-15.6/index.test.tsx | Removes tests tied to the legacy React 15.6 build. |
| src/index.tsx | Adds the new unified entry-point component implementation. |
| src/index.ts | Removes the old default/named-export routing shim. |
| src/index.test.tsx | Adds coverage ensuring ref reaches the underlying div. |
| src/snapshots/index.test.tsx.snap | Adds snapshot in the new test snapshot location. |
| README.md | Documents React 19 requirement, migration path, and ref behavior. |
| package.json | Bumps to 2.0.0, narrows React peer range to >=19.0.0, updates React type deps. |
| MIGRATION.md | Adds a 1.x → 2.0 migration guide explaining breaking changes. |
| .scripts/prepublish.sh | Updates Babel ignore globs to exclude test files from dist/. |
Review details
- Files reviewed: 13/14 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The Requirements section read as though `forwardRef` itself needs React 19. It does not — `forwardRef` has worked since React 16.3. What React 19 changes is that `ref` is passed to function components as an ordinary prop, which is what makes the wrapper unnecessary. Reworded to say that, and to name where `ref` actually lands (`...restProps` on the underlying div). MIGRATION.md already stated this correctly, so no change was needed there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🤖 Applied. Both README findings were right and are fixed in
Consistency sweep: MIGRATION.md already stated the React 19 behaviour correctly, so the README was the only site carrying the misleading version. |
The workflow filtered pull_request on branches: [main], so a PR stacked on another feature branch got no build at all — it could merge into its parent entirely untested. Widened to all pull requests; push stays on main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Major version bump to
2.0.0. Removes the legacy React 15.6 support path and theforwardRefwrapper.Breaking changes
Requires React 19 or later.
peerDependenciesnarrows from^0.14.7 || ^15 || ^16 || ^17 || ^18 || ^19to>=19.0.0.src/react-15.6/held a class component whosecomponentDidUpdatehand-set--aspect-ratiovianode.style.setPropertyas a fallback for facebook/react#6411 — dead code since React 16 writes custom properties from thestyleprop natively.import AspectRatio from 'react-aspect-ratio'andimport { AspectRatio } from 'react-aspect-ratio'keep working and are now identical.forwardRefremoved. React 19 passesrefto function components as an ordinary prop, so it rides through...restPropsto the underlyingdiv. No call-site change; the only visible difference is in a type position (ForwardRefExoticComponent<…>→ usetypeof AspectRatio).Users on React 18 or older should stay on
react-aspect-ratio@1.x— it is unchanged and there is no fix in2.0they would be missing.Other changes
src/react-latest/index.tsx→src/index.tsx; dropped thesrc/index.tsre-export shim.src/types.tsimportsComponentPropsexplicitly instead of leaning on the UMD React global.dist/react-latest/index.test.js) because the babel andtsconfig.publish.jsonignore globs pointed at a nonexistentsrc/__tests__/**. Now excluded properly —dist/is 2 files per target.@types/react/@types/react-dom→^19; dropped the unused@types/react-test-renderer.refprop and the React 19 requirement.refreaches the underlying element, covering theforwardRefremoval.Verification
yarn lint— cleanyarn tsc --noEmit— cleanjest src— 6/6 pass, snapshot unchanged apart from its new path.scripts/prepublish.sh— builds cjs/es/umd/next plus.d.tscleanlyFollow-up
yarn.lockis untouched in this PR. It is replaced outright by react-aspect-ratio#129, which migrates the repo from yarn to pnpm and is stacked on this branch — merge this one first.🤖 Generated with Claude Code