Skip to content

[release]: upgrade stable version to react 19 #169

@halvaradop

Description

@halvaradop

Description

This issue outlines the official upgrade of the stable React version used in the library—from React 18 to React 19. Initially, the library was built using React 18 (published on [insert React 18 release date]) as it was the latest stable version at the time. As React 19 (released on [insert React 19 release date]) introduced significant improvements and changes, the decision was made to upgrade to React 19. However, this upgrade required handling multiple breaking changes that affected the components and core packages of the library.


Breaking Changes Between React 18 and React 19

  1. React.cloneElement Behavior

    • In React 18, it was acceptable to pass undefined props to cloneElement.
    • React 19 throws errors when undefined props are passed, which caused build issues—particularly within the @halvaradop/ui-core package and its Slot component.
  2. forwardRef Usage

    • In React 18, forwardRef was used widely to forward references.
    • In React 19, ref forwarding has improved and is more SSR-friendly. This resulted in a simplification, where forwardRef usage was reduced or removed in many components.
  3. Client Components Directive

    • React 19 enhances SSR (server-side rendering) support.
    • To explicitly mark client-side components, developers must add "use client" at the top of the file when using React hooks (which are not supported on the server). This directive is now required in several files across the library.

Versioning Strategy

To support both major React versions, the library temporarily maintained two separate branches:

  • master: Contained the stable version (React 18)
  • beta: Contained the React 19 version under development

At the time React 19 was still in release candidate status, React 18 was kept as the stable default. However, now that React 19 is officially stable, the decision has been made to:

  • Promote React 19 as the new stable version
  • Reclassify React 18 as the legacy version

This transition was discussed and documented in detail in issue #X.


Supporting Changes for the Upgrade

To ensure a smooth and professional transition, the following changes were introduced across the repository:

  • New and updated documentation:
  • New modular package structure:
    • @halvaradop/ui-utils
    • @halvaradop/ui-core
    • @halvaradop/ui-slot
  • Build process improvements and automated publishing using Bash scripts

Purpose of This Issue

This issue serves as the main reference point documenting:

  • The motivation and reasoning behind the upgrade
  • The major breaking changes that were addressed
  • The steps taken to modernize and improve the library
  • The versioning strategy and current status

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions