Releases: reflex-dev/reflex
v0.6.6.post3
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
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
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
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.
- implement performance mode for existing state size check by @benedikt-bartscher in #4392
Builtin support for existing pydantic v1 and v2 models
State vars can now be typed as pydantic models, with support for modification tracking.
rx.asset
promoted to non-experimental
TBD: docs for new API
- rx._x.asset improvements by @benedikt-bartscher in #3624
Improvements
Streamlined reflex init
workflow
- [GTM-836]Rework Init workflow by @ElijahAhianyo in #4377
Other Improvements
- export Color and ImportDict in top-level namespace by @masenf in #4352
- redesign error boundary screen by @adhami3310 in #4329
- add typing to function vars by @adhami3310 in #4372
- Add template name to reflex init success msg by @ElijahAhianyo in #4349
- fix: do not allow instantiation of State mixins by @benedikt-bartscher in #4347
- add typed dict type checking by @adhami3310 in #4340
- Add datetime to moment by @Alek99 in #4381
- remove deprecation for drawer events by @Lendemor in #4415
- allow to disable checking for the latest package version via env by @benedikt-bartscher in #4407
- Allow bound method as event handler by @benedikt-bartscher in #4348
- enable css props via wrapperStyle for recharts components by @Lendemor in #4447
Bug Fixes
- fix upload argspec being missing by @adhami3310 in #4335
- Only pass Model.fields when casting event args by @masenf in #4356
- Path change after Astral 0.5.0 update by @1Codev in #4336
- [ENG-4098] Deconfuse key/value of State.get_value / dict / get_delta by @masenf in #4371
- fix noSSRComponent imports by @Lendemor in #4386
- fix: Failed to CreateArtifact by @benedikt-bartscher in #4339
- make list suggestions work in rx.input by @Lendemor in #4391
- Don't skip serialization when Var is callable by @masenf in #4399
- ignore rxconfig not in cwd by @adhami3310 in #4398
- fix appearance broken by #3812 by @Lendemor in #4403
- [ENG-4130] Disable typer/rich integration appropriately by @masenf in #4412
- [HOS-313] state.js: when a routing error occurs, delete it by @masenf in #4410
- fix for event handlers in py3.9 by @Lendemor in #4416
- Handle Var passed to
rx.toast
by @masenf in #4405 - allow for 'go.Figure | None' annotation in State by @Lendemor in #4426
- fix mutable default in EventNamespace by @Lendemor in #4420
- [ENG-4137] Handle generic alias passing inspect.isclass check by @masenf in #4427
- [HOS-333] Send a "reload" message to the frontend after state expiry by @masenf in #4442
- rx.upload must include _var_data from props by @masenf in #4463
Version Bumps
- Bump reflex-hosting-cli dep to 0.1.15 for v2 by @masenf in #4355
- Temporarily downpin @radix-ui/themes <3.1.5 by @masenf in #4370
- require typing_extensions >= 4.6.0 by @masenf in #4373
- update cli version by @Kastier1 in #4394
- [maintenance] bump some packages versions by @Lendemor in #4385
- [ENG-4080]Downgrade syntax highlighter to fix
wrapLongLines
issue by @ElijahAhianyo in #4368 - Simon/hosting cli upgrades by @Kastier1 in #4417
Other Changes
- Update bug_report.md by @Alek99 in #4382
- add debug statement to evaluate page by @adhami3310 in #4396
- Remove invitation code logic from reflex logoutv2 @ElijahAhianyo in #4433
New Contributors
Full Changelog: v0.6.5...v0.6.6
v0.6.5
Known Issues
- #4384 Setting the default
appearance
prop inrx.theme
is no longer working
Breaking Changes
rx.App
is now a dataclass that does not accept additional kwargs. Any unrecognized kwargs passed torx.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 regulardict
New Features
New rx.get_state
interface
Support custom bunfig.toml
New Hosting Service CLI
Improvements
Better Typing Support
- add type validation for state setattr by @adhami3310 in #4265
- handle none case in state setattr by @adhami3310 in #4301
- use better typing for on_load by @adhami3310 in #4274
- [ENG-3943]type check for event handler if spec arg are typed by @Lendemor in #4046
- add noop event by @adhami3310 in #4288
- allow for event handlers to ignore args by @adhami3310 in #4282
- improve typing for non decorated events by @adhami3310 in #4308
- add type hinting for plotly by @adhami3310 in #4279
- unbreak pyi plotly by @adhami3310 in #4320
- improve app_src typing by @benedikt-bartscher in #4324
- change custom attr to accept any by @adhami3310 in #4323
- improve typing for serializer decorator by @benedikt-bartscher in #4317
- [ENG-3793] convert event return types to type hints by @adhami3310 in #4331
Experimental Shiki Code Block Features
- [ENG-3892]Shiki codeblock support decorations by @ElijahAhianyo in #4234
- [ENG-4010]Codeblock cleanup in markdown by @ElijahAhianyo in #4233
Refactor Environment Variable Handling
- More env var cleanup by @benedikt-bartscher in #4248
Other Improvements
- Support
locale
prop inrx.moment
by @masenf in #4229 - delay page until _compile gets called by @adhami3310 in #3812
- fix stateful components on delayed evaluation by @adhami3310 in #4247
- make vardata merge not use classmethod by @adhami3310 in #4245
- port enum env var support from #4248 by @benedikt-bartscher in #4251
- expose staticPageGenerationTimeout by @adhami3310 in #4266
- rx.event(background=True) by @adhami3310 in #4263
- components as literal vars by @adhami3310 in #4223
- generate docs for event handlers by @adhami3310 in #4277
- improve page title default by @adhami3310 in #4278
- Add option to scroll to bottom by @picklelo in #4276
- [ENG-759] [ENG-1104] patch
json.dumps
to handle__wrapped__
objects by @masenf in #4166- Support direct usage of
MutableProxy
wrapped objects in JSON APIs (OpenAI, httpx, etc)
- Support direct usage of
- improve object var symantics by @adhami3310 in #4290
- add metainfo to keyevent by @adhami3310 in #4287
Bug Fixes
- Include value._get_all_var_data when ClientStateVar.set_value is used by @masenf in #4161
- client_state: fix fault VarData.merge call by @masenf in #4244
- Remove Duplicated 'gray' colour from ColorType by @lb803 in #4249
- Handle props annotated as list/dict of EventHandler by @masenf in #4257
- add existing path subclass for env checks by @adhami3310 in #4260
- [ENG-4012]Fix shiki copy button animation firing off after clicking copy button by @ElijahAhianyo in #4252
- [ENG-4013] Catch more exceptions for dill pickle fallback by @masenf in #4270
- fix typo in dataeditor prop by @adhami3310 in #4281
- Bugfix/leave gitignore as is by @grahamannett in #4291
- Fix wrong hook by @abulvenz in #4295
- fix call_function events sent from backend by @adhami3310 in #4316
- fix imports with alias from $ by @adhami3310 in #4332
- Only pass Model.fields when casting event args by @masenf in #4356
- fix upload argspec being missing by @adhami3310 in #4335
Documentation
- [ENG-4026]change gallery link to Templates by @ElijahAhianyo in #4283
- [GTM-345]Define component props in class for doc discoverability by @ElijahAhianyo in #4183
- Update overlay props by @tgberkeley in #4261
- default props comment for GraphinTooltip by @carlosabadia in #4101
- add toast classname prop by @carlosabadia in #4310
- [GTM-648]Add Missing Table props by @ElijahAhianyo in #4322
Version Bumps
- update nodejs to lts 22 for real this time by @adhami3310 in #4267
- rollback to 14.2.16 until v15 is more stable by @Lendemor in #4297
- bump python packages version by @Lendemor in #4302
- pin marked to correct version by @adhami3310 in #4313
- Bump reflex-hosting-cli dep to 0.1.15 for v2 by @masenf in #4355
- Temporarily downpin @radix-ui/themes <3.1.5 by @masenf in #4370
Other Changes
- convert test_table to use playwright by @Lendemor in #4241
- cleanup dead code by @benedikt-bartscher in #4271
- unbreak ci lighthouse by @adhami3310 in #4273
- resync steps with task advance by @adhami3310 in #4275
- [ENG-3961] move "warn_if_too_large" logic into BaseState by @masenf in #4284
- raise error when get package manager is not found by @adhami3310 in #4289
- better missing system package message by @adhami3310 in #4306
- move check of path to only check name by @adhami3310 in #4299
- special case field in _isinstance by @adhami3310 in #4298
- bypass pydantic runtime validation for state init by @benedikt-bartscher in #4256
- add codeowners by @Kastier1 in #4312
- stop ignoring some lint rules by @Lendemor in #4311
- mark var methods as private by @adhami3310 in #4319
- test_exception_handlers: add test case that triggers ErrorBoundary by @masenf in #4327
New Contributors
- @lb803 made their first contribution in #4249
- @grahamannett made their first contribution in #4291
Full Changelog: v0.6.4...v0.6.5
v0.6.4
New Features
Make Var System Expandable
A new dispatch mechanism for converting python values into Var and LiteralVar subclasses. This allows component authors and downstream applications to better support custom frontend operations on Python values converted to Javascript values
See Example
This example allows for near drop-in support for working with SQLAlchemy DeclarativeBase
models and will likely be included in a future release:
from collections.abc import Mapping, MutableSet, Sequence
from typing import TypeVar
import dataclasses
import sys
import reflex as rx
import sqlalchemy
import sqlalchemy.orm.exc
from sqlalchemy.orm import DeclarativeBase
class DeclarativeBaseVar(rx.vars.ObjectVar, python_types=DeclarativeBase):
pass
@dataclasses.dataclass(
eq=False,
frozen=True,
**{"slots": True} if sys.version_info >= (3, 10) else {},
)
class LiteralDeclarativeBaseVar(rx.vars.LiteralObjectVar, DeclarativeBaseVar):
_var_value: DeclarativeBase | None = None
T = TypeVar("T")
K = TypeVar("K")
V = TypeVar("V")
@rx.serializer
def serialize_Sequence(s: Sequence[T] | MutableSet[T]) -> list[T]:
return list(s)
@rx.serializer
def serialize_Mapping(m: Mapping[K, V]) -> dict[K, V]:
return dict(m)
@rx.serializer
def serialize_DeclarativeBase(obj: DeclarativeBase) -> dict[str, str]:
s = {}
for attr in sqlalchemy.inspect(type(obj)).all_orm_descriptors.keys():
try:
s[attr] = getattr(obj, attr)
except sqlalchemy.orm.exc.DetachedInstanceError:
# This happens when the relationship was never loaded and the session is closed.
continue
return s
- make var system expandable by @adhami3310 in #4175
max-requests
support to gunicorn (fixed memory leak)
This is a new configurable option in the rx.config but also now has default values.
gunicorn_max_requests
- ( gunicorn / uvicorn )max requests per worker
Defaults value - 100
gunicorn_max_requests_jitter
- (gunicorn only) variance in the max request limit. To prevent all workers restarting at same time
Defaults value - 25
What is max_requests
?
max_requests
is a the maximum number of requests a worker can serve before the manager will kill the worker and restart.
Why is this needed?
gunicorn workers don't release memory after a request. This can cause for a workers to hold on to more and more memory over time. Setting this flag means that after serving N requests the worker is killed, thus releasing the memory, and a new worker is spun up.
How to configure
rx.config(
...
gunicorn_max_requests=50
...
)
Experimental Shiki Codeblock
rx._x.code_block(
"""
print("Original text") # [!code --]
print("Replace original with this") # [!code ++]
name = "John Doe" # [!code highlight]
""",
language="python",
theme="dracula",
use_transformers=True,
can_copy=True,
show_line_numbers=True
)
- [ENG-3848][ENG-3861]Shiki Code block Experimental by @ElijahAhianyo in #4030
dotenv
support added
To use this feature, you must install python-dotenv
separately from reflex.
import reflex as rx
config = rx.Config(
app_name="mycoolapp",
env_file=".env",
)
- HOS-93: add support for .env file by @Kastier1 in #4219
- make python-dotenv optional by @Lendemor in #4222
New rx.dynamic
decorator
Unlike normal UI functions, this decorator allows UI code to directly access State instance values, Python-only APIs, and typical for
and if
statements.
See Example
We can implement a simple Reflex fiddle, that evaluates component strings into UI components and render them. This was previously difficult, as all UI had to compile into react code in the .web
folder. This works by dynamically compiling a JavaScript module using in-window react.
import reflex as rx
class State(rx.State):
component_str = "rx.button('login')"
@rx.dynamic
def evaluated_component(state: State):
try:
component = eval(
state.component_str,
{
"rx": rx,
"State": State,
},
)
except Exception as e:
return rx.text(f"Error: {e}")
if not isinstance(component, rx.Component):
return rx.text("Invalid component")
return component
def index():
return (
rx.hstack(
rx.text_area(
value=State.component_str,
on_change=State.set_component_str,
height="100%",
flex="1",
),
rx.card(evaluated_component(), height="100%", flex="1"),
height="100vh",
padding="1rem",
box_size="border-box",
),
)
- implement rx dynamic by @adhami3310 in #4195
Improvements
Better Type Hinting for Built in Components
- add type hinting to error boundary by @adhami3310 in #4182
- add event types to suneditor by @adhami3310 in #4209
- Add type hinting to dataeditor events by @adhami3310 in #4210
- Add on progress typing to react player by @adhami3310 in #4211
- add additional typing for calling events by @adhami3310 in #4218
Other Improvements
- allow setting run mode via env, add helpers to determine it by @benedikt-bartscher in #4168
- Raise TypeError when
ComputedVar.__init__
gets bad kwargs by @masenf in #4199 - move all environment variables to the same place by @adhami3310 in #4192
- add existing path subclass for env checks by @adhami3310 in #4260
- port enum env var support from #4248 by @benedikt-bartscher in #4251
- [ENG-3970] When normal pickle fails, try dill by @masenf in #4239
Bug Fixes
- use larger or equal for node version check by @adhami3310 in #4189
- check for none before returning which by @adhami3310 in #4187
- fix and test bug in config env loading by @benedikt-bartscher in #4205
- fix inverted alembic file check by @adhami3310 in #4238
- fix: async default setters break setvar by @benedikt-bartscher in #4169
- Fix 'enter_key_submit=True' on 'rx.text_area' by carrying custom_code on debounce by @masenf in #4142
- Handle props annotated as list/dict of EventHandler (#4257)
Version Bumps
- upgrade node to latest lts by @adhami3310 in #4191
- versions bump before 0.6.4 by @Lendemor in #4208
- bump ruff to 0.7.0 by @Lendemor in #4213
Other Changes
- pin AppHarness tests to ubuntu-22.04 runner by @masenf in #4173
- Remove demo command by @Alek99 in #4176
- move client storage classes to their own file by @Lendemor in #4216
- use $ syntax by @adhami3310 in #4237
- test for stateless apps by @Lendemor in #3816
Full Changelog: v0.6.3.post1...v0.6.4
v0.6.3.post1
Post-release fix for hot reload issue RuntimeError: Cannot populate parent states
- [ENG-3989] Ensure non-serialized states are present in StateManagerDisk (#4230)
Full Changelog: v0.6.3...v0.6.3.post1
v0.6.3
New Features
Correct handling of aria
and data
props
Any props passed to a component with aria_
or data_
prefix will be applied directly to the component (previously, these were misinterpreted as style props).
Reflex Code
rx.icon_button("save", aria_label="Save Changes", data_test="arbitrary data")
Generated Output
<button ... aria-label="Save Changes" data-test="arbitrary data"><svg>...</svg></button>
Improvements
Static typing of events and vars
New (optional) rx.Field
, rx.field
and @rx.event
decorators allow pyright and other static type checkers to better understand how event handlers and state vars are handled in reflex, allowing most static type checking to pass without # type: ignore
comments.
import reflex as rx
class MyState(rx.State):
v: rx.Field[int] = rx.field(42)
@rx.event
def set_v(self, v: str):
try:
self.v = int(v)
except ValueError:
pass
def index() -> rx.Component:
return rx.vstack(
rx.heading(MyState.v),
rx.input(
value=MyState.v,
on_change=MyState.set_v,
type="number",
),
)
app = rx.App()
app.add_page(index)
- [ENG-3749] type safe vars by @adhami3310 in #4066
- add type hinting to events by @adhami3310 in #4145
Other Improvements
- Optimize StateManagerDisk by @masenf in #4056
- Reduce pickle size by @masenf in #4063
- fail safely when pickling by @adhami3310 in #4085
- First use environment variable as npm registry by @ruhz3 in #4082
- let users pick state manager mode by @Lendemor in #4041
- Allow setting a different invocation function for EventChain by @masenf in #4160
Bug Fixes
- convert literal type to its variants by @adhami3310 in #4062
- catch CancelledError in lifespan hack for windows by @Lendemor in #4083
- Get default for backend var defined in mixin by @masenf in #4060
- [ENG-3903] bundle next link in window by @adhami3310 in #4064
- misc var improvements by @adhami3310 in #4068
- [ENG-2287] Avoid fetching same state from redis multiple times by @masenf in #4055
- reset backend vars in state.reset() by @adhami3310 in #4087
- fix custom component init by @Lendemor in #4123
- use system npm when REFLEX_USE_SYSTEM_NODE is passed by @adhami3310 in #4133
- Remove wrong event handlers by @adhami3310 in #4136
- fix: Determine str type from value. by @abulvenz in #4143
- remove dictify from state dict by @adhami3310 in #4141
- catch ValueError("I/O operation on closed file.") if frontend crashes by @benedikt-bartscher in #4150
- fix union types for vars by @adhami3310 in #4152
- Change bun link by @adhami3310 in #4162
- change bun install link to main by @adhami3310 in #4164
- only load json if it's not empty by @adhami3310 in #4165
- Handle rx.State subclasses defined in function by @masenf in #4129
- Do not auto-determine generic args if already supplied by @benedikt-bartscher in #4148
- unionize base var fields types by @adhami3310 in #4153
- [ENG-3954] Treat ArrayVar.foreach index as int (#4193)
- LiteralEventChainVar becomes an ArgsFunctionOperation (#4174)
- only treat dict object vars as key value mapping (#4177)
Version Bumps
- add workflow to check dependencies on release branch by @Lendemor in #4050
- upgrade default node to current lts by @adhami3310 in #4086
- update ruff to latest version by @Lendemor in #4081
- Revert Markdown-related frontend dep bumps by @masenf in #4088
- pin AppHarness tests to ubuntu-22.04 runner (#4173)
Documentation
- default props comment for CartesianAxis by @carlosabadia in #4127
- default props comment for CartesianGrid by @carlosabadia in #4126
- default props comment for ReferenceLine by @carlosabadia in #4122
- default props comment for ReferenceArea by @carlosabadia in #4124
- default props comment for Scatter by @carlosabadia in #4118
- default props comment for Area by @carlosabadia in #4115
- default props comment for Line by @carlosabadia in #4117
- default props comment for Bar by @carlosabadia in #4116
- default props comment for Brush by @carlosabadia in #4113
- default props comment for ZAxis by @carlosabadia in #4112
- default props comment for YAxis by @carlosabadia in #4111
- default props comment for XAxis by @carlosabadia in #4110
- default props comment for Legend by @carlosabadia in #4100
- default props comment for PolarAngleAxis by @carlosabadia in #4106
- default props comment for LabelList by @carlosabadia in #4102
- default props comment for treemap by @carlosabadia in #4098
- default props comment for ResponsiveContainer by @carlosabadia in #4099
- default props comment for scatterchart by @carlosabadia in #4096
- default props comment for radarchart by @carlosabadia in #4094
- default props comment for radialbarchart by @carlosabadia in #4095
- default props comment for barchart by @carlosabadia in #4092
- default props comment for composedchart by @carlosabadia in #4093
- areachart default value for base_value by @carlosabadia in #4090
- default props comment for categoricalchartbase by @carlosabadia in #4091
- default props comment for PolarGrid by @carlosabadia in #4107
- default props comment for Reference by @carlosabadia in #4121
- default props comment for funnelchart by @carlosabadia in #4097
- default props comment for Radar by @carlosabadia in #4104
- Add Vietnamese README docs by @nguyenmphu in #4138
- fix docstring by @benedikt-bartscher in #4140
- default props comment for Grid by @carlosabadia in #4125
- default props comment for Funnel by @carlosabadia in #4119
- default props comment for ErrorBar by @carlosabadia in #4120
- default props comment for Cartesian by @carlosabadia in #4114
- default props comment for RadialBar by @carlosabadia in #4105
- default props comment for PolarRadiusAxis by @carlosabadia in #4108
- default props comment for Pie by @carlosabadia in #4103
- default props comment for Axis by @carlosabadia in #4109
Other Changes
- test_dynamic_routes: log on_loads and poll for 60 seconds on order by @masenf in #4089
- only run macOS job on merge by @Lendemor in #4139
- Change the defalut direction of radio group by @Manojvbhat in #4146
New Contributors
- @nguyenmphu made their first contribution in #4138
- @ruhz3 made their first contribution in #4082
- @Manojvbhat made their first contribution in https://github.co...
v0.6.2.post1
Hotfix for Upload
Pin attr-accept
package to 2.2.2 to avoid breakage introduced in 2.2.3 (Released 2024-10-09)
Full Changelog: v0.6.2...v0.6.2.post1
v0.6.2
Known Issues
There is an error persisting states that are created inside a function #4128
def dynamic_state():
class _DynamicState(rx.State):
dynamic: str = ""
return _DynamicState
DynamicState = dynamic_state()
AttributeError: Can't pickle local object 'dynamic_state.<locals>._DynamicState'
Improvements
- All SVG elements are now supported
- feat: Add support for missing SVGs by @ChinoUkaegbu in #3962
- Event triggers can now use
rx.cond
- support eventspec/eventchain in var operations by @adhami3310 in #4038
- Faster state serialization by replacing
dill
with normalpickle
Bug Fixes
- Handle
primary_key
defined insa_column
- [ENG-3870] rx.call_script with f-string var produces incorrect code by @masenf in #4039
- Get default for backend var defined in mixin (#4060)
- catch CancelledError in lifespan hack for windows (#4083)
- convert literal type to its variants (#4062)
Dynamic Components
- Use an equality check instead of startswith by @masenf in #4024
- add of_type to _evaluate by @adhami3310 in #4051
- bundle chakra in window for CSR by @adhami3310 in #4042
- Include emotion inside of dynamic components by @adhami3310 in #4052
Error Messages
- improve granian error message when not installed by @Lendemor in #4037
- [ENG-3476]Setting State Vars that are not defined should raise an error by @ElijahAhianyo in #4007
- set loglevel to info with hosting cli by @adhami3310 in #4043
- default should be warning for subprocesses not info by @adhami3310 in #4049
- remove var operation error by @adhami3310 in #4053
Other Changes
- use pathlib as much as possible by @Lendemor in #3967
- Track the last reflex run time by @ElijahAhianyo in #4045
- move router dataclasses in their own file by @Lendemor in #4044
New Contributors
- @ChinoUkaegbu made their first contribution in #3962
- @Kastier1 made their first contribution in #4021
Full Changelog: v0.6.1...v0.6.2