v0.4.3
New Features
Set initial_value
for rx.var
and rx.cached_var
Provide a placeholder to avoid evaluating computed vars during compile time, for example, if they would perform database queries or other expensive operations.
class MyState(rx.State):
@rx.var(initial_value=42)
def answer(self):
with rx.session() as session:
session.exec(...)
- Initial values for computed vars by @benedikt-bartscher in #2670
State.get_state
allows access to arbitrary substates from within an event handler
class MyState(rx.State):
answer: int = 42
class OtherState(rx.State):
async def get_answer(self):
my_state = await self.get_state(MyState)
print(f"The answer is {my_state}.answer")
Note that get_state
is an async function and must be await
'ed
CLI for Creating and Publishing 3rd Party Components
- Add support for custom components starter by @martinxu9 in #2314
Improvements
Allow accent
as a valid choice in rx.color
- added accent option in color by @wassafshahzad in #2713
Chakra no longer used when rendering Markdown
Sidebar template uses all Radix components
Disallow invalid /api
prefix for frontend page routes
These routes conflict with what NextJS considers special "API routes" and thus do not work for reflex pages.
rx.plotly
now accepts arbitrary config
prop
- Add config to rx.plotly component by @amirmolavi in #2745
Computed Backend-only Vars
- DRAFT PR - Added code for computed backend vars by @wassafshahzad in #2540
Connection Pulser While Websocket is Disconnected
Only show the "Connection Error" banner after a few failed reconnection attempts.
Reconnect Websocket in Stale Tabs
When a browser tab regains focus, automatically reconnect the websocket if it is disconnected.
- Reconnection Logic by @Yummy-Yums in #2743
Bug Fixes
- small update to color scheme high level select by @tgberkeley in #2712
- fix inherited backend var deps by @benedikt-bartscher in #2715
- Avoid frontend errors with getRefValue by @masenf in #2691
- Add missing header variable in el components in init.py file. by @cllatser in #2732
- [REF-2101] Support default_value and default_checked on rx.el.input by @masenf in #2739
- fix initial value for color_mode by @Lendemor in #2741
- fix drawer on_open_change event by @Lendemor in #2755
- call default_factorys on State.reset by @benedikt-bartscher in #2749
Other Changes
- benchmarks.yml: skip benchmarking if the DATABASE_URL is not set by @masenf in #2701
- do not store new_backend_vars in State class by @benedikt-bartscher in #2707
- fix type of value2 in test_state by @benedikt-bartscher in #2708
- pyproject.toml: bump to 0.4.2 by @masenf in #2724
- Update sidebar template README.md by @thedatadavis in #2735
- fix telemetry for init event by @Lendemor in #2736
- Only alert users of reflex upgrade once per project by @ElijahAhianyo in #2731
- fix black+ruff by @benedikt-bartscher in #2750
- add some backend var state inheritance tests by @benedikt-bartscher in #2685
- initial attempt at writing test for urls by @tgberkeley in #2689
New Contributors
- @thedatadavis made their first contribution in #2735
- @amirmolavi made their first contribution in #2745
Full Changelog: v0.4.2...v0.4.3