Skip to content

ENG-6503: use react-router Link instead of rx.el.a#5529

Merged
adhami3310 merged 7 commits into
mainfrom
masenf/react-router-link
Jul 4, 2025
Merged

ENG-6503: use react-router Link instead of rx.el.a#5529
adhami3310 merged 7 commits into
mainfrom
masenf/react-router-link

Conversation

@masenf
Copy link
Copy Markdown
Collaborator

@masenf masenf commented Jul 3, 2025

React Router's Link is a thin wrapper over the plain A element, with client-side routing support. It internally detects absolute links (even those given by a Var at runtime), so there's no good reason why it shouldn't be used.

If downstream users really want the plain link, they can get it through rx.el.elements.a or rx.el.A.create, but the use case should be quite rare.

Updates to lazy_loader to allow overriding the returned __all__ with extra imports that are not in the submodules or submod_attrs.

React Router's Link is a thin wrapper over the plain A element, with
client-side routing support. It internally detects absolute links (even those
given by a Var at runtime), so there's no good reason why it shouldn't be used.

If downstream users really want the plain link, they can get it through
`rx.el.elements.a` or `rx.el.A.create`, but the use case should be quite rare.

Updates to lazy_loader to allow overriding the returned `__all__` with extra
imports that are not in the submodules or submod_attrs.
@linear
Copy link
Copy Markdown

linear Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Major architectural change replacing standard HTML anchor tags with React Router's Link component for optimized client-side routing across the Reflex framework.

  • Added new reflex/components/react_router/dom.py implementing ReactRouterLink component with intelligent handling of internal/external links
  • Modified reflex/components/radix/themes/typography/link.py to use ReactRouterLink as the default link component
  • Updated reflex/utils/lazy_loader.py to support additional all attributes for component exposure
  • Modified reflex/components/el/__init__.py to filter out basic 'a' tag in favor of React Router Link while maintaining backward compatibility
  • Added React Router integration in reflex/components/__init__.py with proper lazy loading support

7 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile


from .dom import ReactRouterLink

link = ReactRouterLink.create
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Consider adding type hints here for better IDE support and type safety: link: Callable[..., Component] = ReactRouterLink.create

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jul 3, 2025

CodSpeed Performance Report

Merging #5529 will not alter performance

Comparing masenf/react-router-link (a62d5ad) with main (86d5b52)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit 19e54dd into main Jul 4, 2025
38 of 41 checks passed
@adhami3310 adhami3310 deleted the masenf/react-router-link branch July 4, 2025 00:04
Sign up for free to 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.

2 participants