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.
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)
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.
- improve client state by @adhami3310 in #4597
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
.
- fix recursive UI by @adhami3310 in #4599
Performance
- Minor performance improvements for state getattribute and setattr by @benedikt-bartscher in #4543
- improve dynamic route vars, no need to compute deps by @benedikt-bartscher in #4551
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 resolverx.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
- chore: update sonner (toast) by @JonZeolla in #4572
- Upgrade Lucide to version 0.469.0 by @celsiusnarhwal in #4571
- poetry 2.0.0 compatibility by @masenf in #4593
Documentation
Other Changes
- add codespell to pre-commit by @Lendemor in #4559
- autodetect print/breakpoints by @Lendemor in #4581
- HOS-400: adding support for config by @Kastier1 in #4540
- Add deprecation message for non-cached var by @masenf in #4591
- test_lifespan: stop periodic events by @masenf in #4600
- Use older python versions for macos actions by @masenf in #4601
New Contributors
- @5quinque made their first contribution in #4577
- @JonZeolla made their first contribution in #4572
- @celsiusnarhwal made their first contribution in #4571
- @KanvaBhatia made their first contribution in #4587
Full Changelog: v0.6.7...v0.6.8