Skip to content

Releases: reflex-dev/reflex

v0.7.2

12 Mar 18:47
Compare
Choose a tag to compare

What's Changed

Deprecated instantiating components through Component.init

You should have probably been doing .create.

Overwrite rx.serializer

You can overwrite a serializer in reflex through @rx.serializer (previously we were erroring here), for example:

@serializer(to=str, overwrite=True) # overwrite flag here suppresses warning about overriding a builtin serializer as an intentional decision
def serialize_uuid(uuid: UUID) -> str:
    return "UUID" + str(uuid)

Use .f with Vars

You can now use the .f in f-strings with state Vars, for example:

class State(rx.State):
  value_of_pi: float = 3.14159265359

rx.text(f"{State.value_of_pi:.2f}")

Note that we now error when you provide a formatter that we don't support. PRs are welcome in extending the functionality beyond :.Xf.

React 19 post-mitigation

Compiler

Component changes

Misc

Full Changelog: v0.7.1...release/reflex-0.7.2

v0.7.1

25 Feb 19:25
73c8dd9
Compare
Choose a tag to compare

Breaking Changes

  • rx.var decorated functions cannot take arguments (it didn't work before, but now it raises exception)

New Features

rx.auto_scroll

A new container that automatically scrolls to the bottom when new content is added.

New Var Operations for StringVar: .title(), .capitalize()

Improvements

Compile with Main Thread by Default

The new default is to compile pages on the main thread, not using an executor. For most normal-sized apps, this is faster because it avoids spinning up threads and associated overhead.

Component Props

Components as props was previously working, however in some situations, the necessary hooks/imports/custom_code associated with the component would not propagate up to the parent component and be lost. This change correctly propagates data from the component as prop for correct code generation.

Performance

Typing

Miscellaneous

Bug Fixes

Version Bumps

Other Changes

New Contributors

Full Changelog: v0.7.0...v0.7.1

v0.7.0

11 Feb 19:32
f34dda2
Compare
Choose a tag to compare

Breaking Changes

Python 3.9 support is no longer supported.

Computed Vars are now cache=True by default

Explicitly set cache=False on Computed Vars that should be updated after every
event, which was the previous default behavior.

The dependency tracking analysis for Computed Vars has been improved to support
async Computed Vars, so there is a possibility for unanticipated behavior change
around tracking dependencies. Please report any bugs encountered in this area.

Previously "CallableVar" shims need to be explicitly called

  • rx.upload_file -> rx.upload_file()
  • rx.selected_files -> rx.selected_files()
  • rx.clear_selected_files -> rx.clear_selected_files()
  • rx.set_color_mode -> rx.set_color_mode()

Deprecation Removals

Usage of these features prior to 0.7.0 printed a deprecation warning, now they will result in an error.

  • rx.chakra is removed, use import reflex_chakra as rc instead.

  • rx.background is removed, use rx.event(background=True) instead.

  • rx.Component._create_event_chain is removed, use rx.EventChain.create instead.

  • external prop for rx.redirect is removed.

  • Unannotated event handler arguments will now raise MissingAnnotationError.

  • Many internal exceptions were renamed to add a trailing Error suffix if that was missing.

  • rx._x.asset is removed, use rx.asset instead.

  • Passing a str argument to rx.utils.console.set_log_level will now raise TypeError.

  • Removals from rx.utils.exec:

    • is_frontend_only -> rx.config.environment.REFLEX_FRONTEND_ONLY.get()
    • is_backend_only -> rx.config.environment.REFLEX_BACKEND_ONLY.get()
    • should_skip_compile -> rx.config.environment.REFLEX_SKIP_COMPILE.get()
  • rx.utils.format.format_event_chain is removed, use str(rx.Var.create(chain)) instead.

  • _var_is_local and _var_is_string removed from rx.Var.create.

  • Computed Vars without a return type annotation will raise UntypedComputedVarError.

  • removing deprecated features for 0.7.0 and removing py3.9 support by @Lendemor in #4586

rx.App fields for internal use now have a _ prefix

  • rename private fields with leading underscore in App by @Lendemor in #4642

New Features

reflex rename

A new command to rename an app.

rx.var now supports async functions

An rx.var computed var can now wrap an async function, which can access
arbitrary state via get_state and var values via get_var_value.

Dependency tracking across states is supported, but there may be edge cases in
the new implementation that prevent depedencies from being automatically
identified. You can pass explicit dependencies to the deps argument, and can
add dependencies at runtime via cls.computed_vars[var_name].add_dependency.
For best results, pass a globally imported state class to get_state and assign
the return value to a local variable in the function.

"Built with Reflex" badge

To raise awareness of Reflex, a sticky "Built with Reflex" badge is added to the
lower right corner of each page.

For subscribers of Reflex Cloud, this badge can be disabled by setting
show_built_with_reflex=False in rxconfig.py or SHOW_BUILT_WITH_REFLEX=0 in
the environment.

For more information see: https://reflex.dev/docs/hosting/reflex-branding/

Improvements

Support For Dynamic Icon name

Previously the recommendation was to use rx.match to map icons, because the
icon name itself could not be a Var.

With rx.dynamic_icon, the name can now be a Var, but performance may be
affected by dynamic loading.

Support for Specifying Custom App Module

A new config knob is added to rxconfig.py, to load the app from a module other than the default.

config = rx.Config(
    app_name="my_app",
    app_module_import="some_package.my_actual_app_module",
)

The app module should be importable by name with the current PYTHONPATH / sys.path, and contain an app attribute.

Display Warning for Frontend/Backend Version Mismatch

When the frontend and backend versions do not match, a warning is displayed in the console.

Typing

Recharts

Avoid Leaked Websocket connections

Miscellaneous

Bug Fixes

Read more

v0.6.8

10 Jan 17:27
fea0ceb
Compare
Choose a tag to compare

New Features

New API: rx.EventChain.create

This new interface makes it easier to transform EventType (EventHandler, EventSpec, and lambda - as accepted by component event triggers) into EventChain to be rendered in hook calls or rx.call_script / rx.call_function invocations.

  • Move _create_event_chain to EventChain.create by @masenf in #4557

New API: BaseState.get_var_value

Similar to get_state, this API provides access to a Var defined in another state. If the value is mutable, changing it will be reflected in the other state. This API is intended for use with ComponentState implementations that want to "borrow" data from another state.

Show Example Code

from typing import ClassVar

import reflex as rx


class MyState(rx.State):
    data: list[dict] = []


class Appender(rx.ComponentState):
    _data: ClassVar[rx.Var]

    async def add_value(self, form_data: dict):
        (await self.get_var_value(self._data)).append(form_data)

    @classmethod
    def get_component(cls, data: rx.Var[list[dict]]) -> rx.Component:
        cls._data = data
        return rx.card(
            rx.form(
                rx.vstack(
                    rx.input(placeholder="Name", name="name", autofocus=True),
                    rx.input(placeholder="Email", name="email"),
                    rx.button("Submit", type="submit"),
                ),
                reset_on_submit=True,
                on_submit=cls.add_value,
            ),
        )


appender = Appender.create


def index() -> rx.Component:
    return rx.vstack(
        rx.foreach(
            MyState.data,
            lambda d: rx.text(d.to_string()),
        ),
        appender(data=MyState.data),
    )


app = rx.App()
app.add_page(index)
  • BaseState.get_var_value helper to get a value from a Var by @masenf in #4553

Improvements

Add .endswith() var operation for strings

Simpler API for rx._x.client_state

Use client state vars anywhere in the tree instead of having to include them and use them separately.

Support Recursive UI elements with @rx.memo

See example code in PR. This allows the rendering of trees and other self-referential structures using rx.foreach.

Performance

Miscellaneous

  • fix health check and skip not needed tasks by @Lendemor in #4563
  • [ENG-4083] Track internal changes in dataclass instances by @masenf in #4558
  • use position in vardata to mark internal hooks by @Lendemor in #4549
  • Enable automatic retry on redis errors by @masenf in #4595

Bug Fixes

  • Add expire_on_commit=False for async sessions by @masenf in #4582
  • Do not allow call_function callback argument to be added afterwards by @masenf in #4552
  • [ENG-2157] [Refix] Allow rx.download to resolve rx.get_upload_url by @masenf in #4470
  • fixes #4578 - correct the way dim_props created by @KanvaBhatia in #4587
  • unbreak link _hover by @masenf in #4537
  • [ENG-4255] Code blocks lead to redefined const in web page by @masenf in #4598

Version Bumps

Documentation

Other Changes

New Contributors

Full Changelog: v0.6.7...v0.6.8

v0.6.7

17 Dec 18:11
61caf14
Compare
Choose a tag to compare

Deprecations

  • app.add_custom_404_page is deprecated -- use app.add_page(..., route="/404") instead.
  • external prop of rx.redirect is renamed to is_external for consistency.

New Features

async_db_url and rx.asession

Builtin support for async database operations using sqlmodel. Proper usage requires the following:

  1. Install greenlet for sqlalchemy to use async operations.
  2. Install an appropriate async-capable database driver (aiosqlite, pyscopg)
  3. Set ASYNC_DB_URL in the environment that references the async db driver. This should point to the same database as specified in DB_URL, which should still be set for handling alembic migrations and for use in computed vars, etc.
  4. Use async with rx.asession() as asession -- await most operations on the asession.

Async DB operations are preferred in event handlers to avoid blocking other users on the server.

Var Operations for datetime values

[Wrapping React] new deps and position fields in VarData

This allows for customization and control of where hooks are rendered relative to other hooks and memoized event handlers. Deps allows for specification of vars that memoized event handlers depend on.

Improvements

More Efficient Database Connection Pooling

Each time rx.session was used, it was creating a new pool and not reusing connections.

  • Reuse the sqlalchemy engine once it's created by @masenf in #4493

Linting

Performance

Miscellaneous

Bug Fixes

Documentation

Version Bumps

Other Changes

New Contributors

Full Changelog: v0.6.6.post3...v0.6.7

v0.6.6.post3

10 Dec 03:04
49caf9d
Compare
Choose a tag to compare

fix non-interactive flag in deploy command by @Lendemor in #4498

Full Changelog: v0.6.6.post2...v0.6.6.post3

v0.6.6.post2

05 Dec 09:21
7c81dca
Compare
Choose a tag to compare

Fixup stray loginv2 command in help text

This should have been removed in 0.6.6.post1, but it was missed

Bump reflex-hosting-cli requirement to 0.1.29

Full Changelog: v0.6.6.post1...v0.6.6.post2

v0.6.6.post1

05 Dec 07:27
dc99778
Compare
Choose a tag to compare

Update CLI for Reflex Cloud hosting

  • remove v2 commands (#4478)
  • [HOS-373][HOS-372]Logout should not open the browser (#4475)
  • [ENG-4149] require login to deploy named templates (#4450)

Full Changelog: v0.6.6...v0.6.6.post1

v0.6.6

03 Dec 05:00
0c81922
Compare
Choose a tag to compare

New Features

.temporal event action drops events when backend is not connected

New "performance mode" options

Allow disabling or modifying various guardrails and checks performed by reflex.

Builtin support for existing pydantic v1 and v2 models

State vars can now be typed as pydantic models, with support for modification tracking.

  • [ENG-3953] Support pydantic BaseModel (v1 and v2) as state var by @masenf in #4338

rx.asset promoted to non-experimental

TBD: docs for new API

Improvements

Streamlined reflex init workflow

Other Improvements

Bug Fixes

Version Bumps

Other Changes

New Contributors

Full Changelog: v0.6.5...v0.6.6

v0.6.5

12 Nov 21:50
3e9f346
Compare
Choose a tag to compare

Known Issues

  • #4384 Setting the default appearance prop in rx.theme is no longer working

Breaking Changes

  • rx.App is now a dataclass that does not accept additional kwargs. Any unrecognized kwargs passed to rx.App will now raise an exception.
  • Event handlers that accept annotated rx.Base subclasses as arguments will receive an instance of the annotated class instead of a regular dict

New Features

New rx.get_state interface

  • expose rx.get_state() to get instance of state from anywhere by @Lendemor in #3959

Support custom bunfig.toml

New Hosting Service CLI

Improvements

Better Typing Support

Experimental Shiki Code Block Features

Refactor Environment Variable Handling

Other Improvements

Bug Fixes

Documentation

Version Bumps

Other Changes

New Contributors

Full Changelog: v0.6.4...v0.6.5