Skip to content

Conversation

@jrgarciadev
Copy link
Member

@jrgarciadev jrgarciadev commented Oct 20, 2025

This pull request refactors several React component implementations to remove the use of React.forwardRef, simplify type definitions, and clean up context provider usage. The changes focus on improving code clarity, maintainability, and consistency across the accordion, alert, avatar, and button components. The most important changes are grouped below by theme.

Refactoring Components to Remove forwardRef

  • All major components in accordion.tsx, alert.tsx, avatar.tsx, and button.tsx have been refactored to use plain functional components instead of React.forwardRef. This simplifies the code, removes unnecessary ref handling, and streamlines type definitions. [1] [2] [3] [4] [5] [6] [7]

React 19 docs: https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop

Context Provider Simplification

  • The context providers in accordion.tsx, alert.tsx, and avatar.tsx have been changed from <Context.Provider> to direct <Context> usage, eliminating redundant provider boilerplate and making context usage more idiomatic. [1] [2] [3]

React 19 docs: https://react.dev/blog/2024/12/05/react-19#context-as-a-provider

Type Definition Improvements

  • Component props now use React.ComponentProps or similar utility types for better compatibility and clarity, replacing custom or primitive prop types. [1] [2] [3]
  • Unused or redundant prop types and imports have been removed to reduce clutter. [1] [2]

Removal of Display Names

  • All displayName assignments for components have been removed except for AlertAction and AlertClose, which now use a simplified display name. This reduces unnecessary metadata and aligns with current best practices. [1] [2] [3]

Avatar Component Modernization

  • The avatar.tsx component now uses the latest Radix UI Avatar API, updates prop handling for AvatarImage, and improves fallback and image loading logic for better reliability and flexibility. [1] [2]

These changes collectively modernize and simplify the codebase, making it easier to maintain and extend.


Note

Rewrites many UI components to drop forwardRef in favor of ref-as-prop and Context-as-Provider, updates types/APIs (notably Avatar), and trims legacy exports/displayNames.

  • Framework-wide refactor (React 19 patterns):
    • Replace React.forwardRef with plain functions using ref-as-prop; switch from <Context.Provider> to <Context value={...}> across components.
    • Simplify render props and class composition usage; remove most displayName assignments.
  • Type & API updates:
    • Adopt React.ComponentProps<...> and specific primitive prop types; normalize props (e.g., svg, div, Heading).
    • Adjust slot/context types via variant-based factories.
  • Component-specific changes:
    • Avatar: Move to @radix-ui/react-avatar namespace API (Root/Image/Fallback), expand AvatarImage props (srcSet/sizes/loading/crossOrigin), integrate useImage status handling.
    • Disclosure/Accordion: Remove mergeRef utility; simplify heading/indicator/trigger/panel/body signatures.
    • Inputs/Fields: Streamline Input, TextArea, Label, Description, FieldError, Form signatures and styling hooks.
    • Collections/Navigation: Refactor Calendar, ListBox, Tabs, Slider, RadioGroup, Switch, Popover, Tooltip, Card, Chip, Button, CloseButton, Kbd, Link, Separator, Skeleton, Spinner to new patterns.
  • Exports cleanup:
    • Remove alias/named re-exports like Root, Item, Marks, etc., consolidating to primary component exports.

Written by Cursor Bugbot for commit c55cc16. This will update automatically on new commits. Configure here.

…s and explicit ref declarations from all components
@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

⚠️ No Changeset found

Latest commit: c55cc16

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
heroui Error Error Oct 20, 2025 6:52pm
heroui-sb Ready Ready Preview Comment Oct 20, 2025 6:52pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@jrgarciadev jrgarciadev changed the title refactor: migrate to React 19 ref pattern - remove forwardRef wrapper… refactor: migrate to React 19 ref pattern Oct 20, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/remove-forward-ref

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jrgarciadev jrgarciadev changed the title refactor: migrate to React 19 ref pattern refactor: migrate to React 19 ref pattern & Context Oct 20, 2025
@jrgarciadev jrgarciadev marked this pull request as ready for review October 20, 2025 21:09
@jrgarciadev jrgarciadev merged commit ac27fe9 into alpha-35 Oct 20, 2025
2 of 3 checks passed
@jrgarciadev jrgarciadev deleted the refactor/remove-forward-ref branch October 20, 2025 21:09
{kbdKeysMap[keyValue]}
</abbr>
);
};
Copy link

Choose a reason for hiding this comment

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

{children}
</TextPrimitive>
);
};
Copy link

Choose a reason for hiding this comment

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

Bug: Ref Ignored in Functional Components

After the refactor from React.forwardRef to plain functional components, several components (like Label, Description, Input, Separator, Text, FieldError, Link, and LinkIcon) declare a ref prop in their interfaces but don't destructure or forward it to their underlying elements. This causes refs to be silently ignored, breaking ref functionality for consumers.

Additional Locations (6)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♿ Scope: v3 Related to HeroUI v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants