Deprecate @rx.dynamic

Merged
FA
1d ago
+115-20

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Deprecation (non-breaking: @rx.dynamic keeps working and now warns)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

Deprecates the @rx.dynamic decorator; it will be removed in 1.0. Only the decorator is deprecated here; the rest of the dynamic-component machinery is left alone and can be removed together with it.

  • Runtime: applying the decorator calls console.deprecate, so the warning points at the user's decorated definition:
    @rx.dynamic has been deprecated. It will be completely removed in 1.0. (app/page.py:12)
    
  • console.deprecate() (reflex-base): reason and deprecation_version are now optional; an empty one is left out of the message. Existing callers pass both, so their messages are unchanged. Covered by test_deprecate_omits_empty_reason_and_version.
  • Type level: a typing_extensions.deprecated stub inside TYPE_CHECKING, following the _load_config pattern in reflex_base/config.py. Checked that pyright reports rx.dynamic as deprecated through the rx. namespace.
  • Test: test_dynamic_is_deprecated in tests/units/test_state.py checks the full warning and its source location. It failed before the change. The existing _wrapped_handler_warnings helper is renamed _deprecation_warnings so it can be reused.
  • News: news/+deprecate-rx-dynamic.deprecation.md and packages/reflex-base/news/+deprecate-optional-reason-version.feature.md.

examples/playground still uses @rx.dynamic and will log the warning until the decorator is removed.

Testing

  • uv run ruff check ., uv run ruff format --check . and uv run pyright reflex tests are clean.
  • uv run pytest tests/units: the only failures are 264 tests (reflex_cli/v2 cloud API and reflex_bench browser drivers) that need network or browser access the sandbox doesn't have. They fail identically on the base commit.

https://claude.ai/code/session_01LwJUCT1HV3LAGGnxS82EWr


Generated by Claude Code