Reflex

Latest version: v0.6.5

Safety actively analyzes 681775 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 14

14.2.13

* bump nextjs version by Lendemor in https://github.com/reflex-dev/reflex/pull/3992

Miscellaneous

* [ENG-3717] [flexgen] Initialize app from refactored code by masenf in https://github.com/reflex-dev/reflex/pull/3918
* Added fill color for progress by wassafshahzad in https://github.com/reflex-dev/reflex/pull/3926
* Use tailwind typography plugin by default by minimav in https://github.com/reflex-dev/reflex/pull/3593
* disable prose by default for rx.html by adhami3310 in https://github.com/reflex-dev/reflex/pull/4001
* use `class_name="prose"` to enable default formatting for `rx.html`
* allow link as metatags by Lendemor in https://github.com/reflex-dev/reflex/pull/3980
* allow classname to be state vars by adhami3310 in https://github.com/reflex-dev/reflex/pull/3991
* default on_submit in form set to prevent_default by Lendemor in https://github.com/reflex-dev/reflex/pull/4005

Bug Fixes

* [ENG-3824]Make AI template use light mode by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3963
* don't camel case keys of dicts in style by adhami3310 in https://github.com/reflex-dev/reflex/pull/3982
* add missing message when running in backend_only by Lendemor in https://github.com/reflex-dev/reflex/pull/4002
* [ENG-3849] Track backend-only vars that are declared without a default value by masenf in https://github.com/reflex-dev/reflex/pull/4016
* improve lifespan typecheck and debug by Lendemor in https://github.com/reflex-dev/reflex/pull/4014

Documentation

* fix: Adding in-line comments for the segmented control: value and on_change by elviskahoro in https://github.com/reflex-dev/reflex/pull/3933
* fix: Adding code comments for segmented control type by elviskahoro in https://github.com/reflex-dev/reflex/pull/3935

Other Changes

* add some unit tests for coverage by Lendemor in https://github.com/reflex-dev/reflex/pull/3947
* always print passed_type by adhami3310 in https://github.com/reflex-dev/reflex/pull/3950
* remove unused badge by Lendemor in https://github.com/reflex-dev/reflex/pull/3955
* add some more tests by Lendemor in https://github.com/reflex-dev/reflex/pull/3965
* use svg elements instead of raw html for logo by Lendemor in https://github.com/reflex-dev/reflex/pull/3978
* bump to 0.6.1 for further dev by masenf in https://github.com/reflex-dev/reflex/pull/3995
* reorganize all tests in a single top folder by Lendemor in https://github.com/reflex-dev/reflex/pull/3981
* Update markdown component map to use new rx.code_block.theme enum by masenf in https://github.com/reflex-dev/reflex/pull/3996
* remove all runtime asserts by Lendemor in https://github.com/reflex-dev/reflex/pull/4019

New Contributors
* minimav made their first contribution in https://github.com/reflex-dev/reflex/pull/3593
* LeoGrosjean made their first contribution in https://github.com/reflex-dev/reflex/pull/4004

**Full Changelog**: https://github.com/reflex-dev/reflex/compare/v0.6.0...v0.6.1

3.0

* `rx.spinner` - new component for indeterminate loading
* `rx.skeleton` - new component for placeholder loading
* `loading` prop available for
* `rx.button`
* `rx.icon_button`
* `rx.spinner` and `rx.skeleton` -- use `loading=State.is_loading` instead of using `rx.cond`
* `rx.data_list` - new component for showing key value pairs
* `rx._x.progress` - experimental radix themes progress component, supports `duration` for indeterminate progress.

Radix 3.0 by Lendemor in https://github.com/reflex-dev/reflex/pull/3159

New Public API for wrapping Components

To make wrapping components easier and less error prone, the following functions should be overridden when wrapping components:

* `add_style` - return an `rx.style.Style` for default component styles
* `add_imports` - return a dictionary of `{"library-name0.5.0": {"tag1", "tag2", "tag3"}}` of required imports -- it will automatically be merged with the other component imports.
* `add_hooks` - return a list of javascript snippets that will go inside the component function -- it will be deduped automatically with any other hooks
* `add_custom_code` - return a list of javascript snippets that will go inside the module for each page the component is included in.

With these new methods, Reflex will internally call them for each parent class your component inherits from, so there is no need to call `super().add_*` or do any merging yourself.

* [REF-2523] Implement new public Component API by masenf in https://github.com/reflex-dev/reflex/pull/3203
* add_style api by Lendemor in https://github.com/reflex-dev/reflex/pull/3202

`State.setvar(var_name, value)`

A less magic version of the automatic `State.set_x` setter functions which accept the `var_name` as a string.

* [REF-2273] Implement .setvar special EventHandler by masenf in https://github.com/reflex-dev/reflex/pull/3163

Experimental Toast Component

python
def try_some_toast():
return rx.fragment(
rx.button("🥂", on_click=rx._x.toast.info("Cheers"), variant="outline"),
rx._x.toast.provider(),
)


* add toast component by Lendemor in https://github.com/reflex-dev/reflex/pull/3186
Generic `.throttle` and `.debounce` for all Event types

python
class ThrottleState(rx.State):
last_event: datetime.datetime = datetime.datetime.now()

def handle_mouse_move(self):
self.last_event = datetime.datetime.now()

def throttle_example():
return rx.box(
ThrottleState.last_event,
background_color=rx.color("red", 7),
width="500px",
height="500px",
on_mouse_move=ThrottleState.handle_mouse_move.throttle(500), one event every 500ms
)


* Implement `throttle` and `debounce` as event actions by masenf in https://github.com/reflex-dev/reflex/pull/3091

`rx.container` new prop `stack_children_full_width`

For a nice streamlit-like wide layout, use the following snippet:

python
def index():
return rx.container(
rx.vstack(content()),
stack_children_full_width=True,
)


This will cause all vstack/hstack children and most stack child components to have `width="100%"` automatically, which provides a nice aesthetic for many apps without applying CSS to individual components.

* [REF-2574] Default width for Stack (+children) and default padding for container by masenf in https://github.com/reflex-dev/reflex/pull/3104

Improvements

Unify on `ruff-format`
* ruff-format: unify Black with Ruff `v0.1` by Borda in https://github.com/reflex-dev/reflex/pull/2837
* sync ruff version in pyproject.toml with the precommit one by Lendemor in https://github.com/reflex-dev/reflex/pull/3150

Error Messages
* [REF-2636]Improve Error message for unsupported event trigger by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3147
* prevent shadowing by Lendemor in https://github.com/reflex-dev/reflex/pull/3221
* Better error when a computed var has the same name as an existing state var.
* [REF-2643]Throw Errors for duplicate Routes by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3155
* [REF-2622]Throw warning for incompatible uvicorn version on windows by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3246

`rx.color_mode` changes

* `rx.color_mode.button` now has built in positioning prop for floating button
* IconButton for color_mode with nice default and a position props to control it by Lendemor in https://github.com/reflex-dev/reflex/pull/3165

Default style for `rx.upload`

* Refactor upload component and add styled upload component by Ifechukwu001 in https://github.com/reflex-dev/reflex/pull/3035

Use Alembic Batch Mode for `reflex db makemigrations`

This improves compatibility with the default sqlite database when re-typing columns.

* [REF-2658] Alembic should use batch mode for autogenerate by masenf in https://github.com/reflex-dev/reflex/pull/3223

README
* add color dalle code example by tgberkeley in https://github.com/reflex-dev/reflex/pull/3108
* a little correction in the "es" docs by JLDev-coder in https://github.com/reflex-dev/reflex/pull/3127
* Add Japanese README.md file by PeterYusuke in https://github.com/reflex-dev/reflex/pull/3234

Miscellaneous

* add default underline for links by Lendemor in https://github.com/reflex-dev/reflex/pull/3148
* Expose `color_scheme` on TabsTrigger by masenf in https://github.com/reflex-dev/reflex/pull/3112
* update blank template by Lendemor in https://github.com/reflex-dev/reflex/pull/3219
* Clean up config and app API by picklelo in https://github.com/reflex-dev/reflex/pull/3197
* Fixed unused kwargs in reflex.App by Snaipergelka in https://github.com/reflex-dev/reflex/pull/3170
* Now able to pass a custom `SocketIO` instance

Bugfixes

* [REF-2587] Ignore top-level theme appearance by masenf in https://github.com/reflex-dev/reflex/pull/3119
* avoids "flickering" when the top-level appearance differs from user selected mode
* [REF-2619] Re-init when the template is out of date by masenf in https://github.com/reflex-dev/reflex/pull/3121
* Fixed app name validation by Snaipergelka in https://github.com/reflex-dev/reflex/pull/3146
* extend rx.input allowed types by Lendemor in https://github.com/reflex-dev/reflex/pull/3149
* [REF-2682] Foreach over dict uses Tuple arg value by masenf in https://github.com/reflex-dev/reflex/pull/3160
* Improve nested foreach when dict has complex values
* Update CodeBlock class to accept rx.color in custom_style by khhan0130 in https://github.com/reflex-dev/reflex/pull/3168
* Windows `--frontend-only` fix ctrl + c by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3181
* [REF-2676][REF-2751]Windows Skip ARM devices on bun install + Telemetry by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3212
* icon_button: Icon size should be specified as int pixels, not str by masenf in https://github.com/reflex-dev/reflex/pull/3247
* copy background task marker by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3255
* Can now define background tasks in a state mixin
* Dynamic NoSSRComponent properly renders in prod mode when using State/event handlers

Dependencies
* Bump bun version to 1.1.5 by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3176
* Windows Pin Bun version by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3192
* Windows Pin Version followup (Use Windows Install Link) by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/3193
* [REF-2764] dep update 0.5.0 by masenf in https://github.com/reflex-dev/reflex/pull/3245
* gunicorn 22.0.0 with security fix

Other Changes
* separate DECORATED_PAGES per reflex app by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3102
* fix: args issue in `__init__` of App class by nautics889 in https://github.com/reflex-dev/reflex/pull/3141
* [REF-2620] Fallback to npm (not bun) by masenf in https://github.com/reflex-dev/reflex/pull/3138
* pin macos version for CI by Lendemor in https://github.com/reflex-dev/reflex/pull/3145
* [REF-2618] Send template info in init telemetry event by martinxu9 in https://github.com/reflex-dev/reflex/pull/3153
* Integration testing: Firefox compatibility by masenf in https://github.com/reflex-dev/reflex/pull/3162
* Improved get_attribute_access_type by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3156
* custom component install command to install current project in editable mode by martinxu9 in https://github.com/reflex-dev/reflex/pull/3200
* migrate deprecated redis.close to redis.aclose by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3199
* allow optional props with None default value by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3179
* Allow StatefulComponent to also be rendered via `__str__` by masenf in https://github.com/reflex-dev/reflex/pull/3211
* Improved get_attribute_access_type tests by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3180
* Improved implicit harness app names by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3237
* do not access state `__subclasses__`, prevent issues with AppHarness by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3143
* fix screenshot filenames by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3241
* minor test exp_not_equal fixup by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/3256


New Contributors
* nautics889 made their first contribution in https://github.com/reflex-dev/reflex/pull/3141
* Borda made their first contribution in https://github.com/reflex-dev/reflex/pull/2837
* Snaipergelka made their first contribution in https://github.com/reflex-dev/reflex/pull/3146
* Ifechukwu001 made their first contribution in https://github.com/reflex-dev/reflex/pull/3035
* JLDev-coder made their first contribution in https://github.com/reflex-dev/reflex/pull/3127
* khhan0130 made their first contribution in https://github.com/reflex-dev/reflex/pull/3168

**Full Changelog**: https://github.com/reflex-dev/reflex/compare/v0.4.9...v0.5.0

0.6.5

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 https://github.com/reflex-dev/reflex/pull/3959

Support custom `bunfig.toml`

* allow custom bunfig.toml file by Lendemor in https://github.com/reflex-dev/reflex/pull/4280

New Hosting Service CLI

* Adding hosting v1 support by Kastier1 in https://github.com/reflex-dev/reflex/pull/4309
* update cli version by Kastier1 in https://github.com/reflex-dev/reflex/pull/4333

Improvements

Better Typing Support
* add type validation for state setattr by adhami3310 in https://github.com/reflex-dev/reflex/pull/4265
* handle none case in state setattr by adhami3310 in https://github.com/reflex-dev/reflex/pull/4301
* use better typing for on_load by adhami3310 in https://github.com/reflex-dev/reflex/pull/4274
* [ENG-3943]type check for event handler if spec arg are typed by Lendemor in https://github.com/reflex-dev/reflex/pull/4046
* add noop event by adhami3310 in https://github.com/reflex-dev/reflex/pull/4288
* allow for event handlers to ignore args by adhami3310 in https://github.com/reflex-dev/reflex/pull/4282
* improve typing for non decorated events by adhami3310 in https://github.com/reflex-dev/reflex/pull/4308
* add type hinting for plotly by adhami3310 in https://github.com/reflex-dev/reflex/pull/4279
* unbreak pyi plotly by adhami3310 in https://github.com/reflex-dev/reflex/pull/4320
* improve app_src typing by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4324
* change custom attr to accept any by adhami3310 in https://github.com/reflex-dev/reflex/pull/4323
* improve typing for serializer decorator by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4317
* [ENG-3793] convert event return types to type hints by adhami3310 in https://github.com/reflex-dev/reflex/pull/4331

Experimental Shiki Code Block Features
* [ENG-3892]Shiki codeblock support decorations by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/4234
* [ENG-4010]Codeblock cleanup in markdown by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/4233

Refactor Environment Variable Handling
* More env var cleanup by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4248

Other Improvements
* Support `locale` prop in `rx.moment` by masenf in https://github.com/reflex-dev/reflex/pull/4229
* delay page until _compile gets called by adhami3310 in https://github.com/reflex-dev/reflex/pull/3812
* fix stateful components on delayed evaluation by adhami3310 in https://github.com/reflex-dev/reflex/pull/4247
* make vardata merge not use classmethod by adhami3310 in https://github.com/reflex-dev/reflex/pull/4245
* port enum env var support from 4248 by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4251
* expose staticPageGenerationTimeout by adhami3310 in https://github.com/reflex-dev/reflex/pull/4266
* rx.event(background=True) by adhami3310 in https://github.com/reflex-dev/reflex/pull/4263
* components as literal vars by adhami3310 in https://github.com/reflex-dev/reflex/pull/4223
* generate docs for event handlers by adhami3310 in https://github.com/reflex-dev/reflex/pull/4277
* improve page title default by adhami3310 in https://github.com/reflex-dev/reflex/pull/4278
* Add option to scroll to bottom by picklelo in https://github.com/reflex-dev/reflex/pull/4276
* [ENG-759] [ENG-1104] patch `json.dumps` to handle `__wrapped__` objects by masenf in https://github.com/reflex-dev/reflex/pull/4166
* Support direct usage of `MutableProxy` wrapped objects in JSON APIs (OpenAI, httpx, etc)
* improve object var symantics by adhami3310 in https://github.com/reflex-dev/reflex/pull/4290
* add metainfo to keyevent by adhami3310 in https://github.com/reflex-dev/reflex/pull/4287

Bug Fixes
* Include value._get_all_var_data when ClientStateVar.set_value is used by masenf in https://github.com/reflex-dev/reflex/pull/4161
* client_state: fix fault VarData.merge call by masenf in https://github.com/reflex-dev/reflex/pull/4244
* Remove Duplicated 'gray' colour from ColorType by lb803 in https://github.com/reflex-dev/reflex/pull/4249
* Handle props annotated as list/dict of EventHandler by masenf in https://github.com/reflex-dev/reflex/pull/4257
* add existing path subclass for env checks by adhami3310 in https://github.com/reflex-dev/reflex/pull/4260
* [ENG-4012]Fix shiki copy button animation firing off after clicking copy button by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/4252
* [ENG-4013] Catch more exceptions for dill pickle fallback by masenf in https://github.com/reflex-dev/reflex/pull/4270
* fix typo in dataeditor prop by adhami3310 in https://github.com/reflex-dev/reflex/pull/4281
* Bugfix/leave gitignore as is by grahamannett in https://github.com/reflex-dev/reflex/pull/4291
* Fix wrong hook by abulvenz in https://github.com/reflex-dev/reflex/pull/4295
* fix call_function events sent from backend by adhami3310 in https://github.com/reflex-dev/reflex/pull/4316
* fix imports with alias from $ by adhami3310 in https://github.com/reflex-dev/reflex/pull/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 https://github.com/reflex-dev/reflex/pull/4283
* [GTM-345]Define component props in class for doc discoverability by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/4183
* Update overlay props by tgberkeley in https://github.com/reflex-dev/reflex/pull/4261
* default props comment for GraphinTooltip by carlosabadia in https://github.com/reflex-dev/reflex/pull/4101
* add toast classname prop by carlosabadia in https://github.com/reflex-dev/reflex/pull/4310
* [GTM-648]Add Missing Table props by ElijahAhianyo in https://github.com/reflex-dev/reflex/pull/4322

Version Bumps
* update nodejs to lts 22 for real this time by adhami3310 in https://github.com/reflex-dev/reflex/pull/4267
* rollback to 14.2.16 until v15 is more stable by Lendemor in https://github.com/reflex-dev/reflex/pull/4297
* bump python packages version by Lendemor in https://github.com/reflex-dev/reflex/pull/4302
* pin marked to correct version by adhami3310 in https://github.com/reflex-dev/reflex/pull/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 https://github.com/reflex-dev/reflex/pull/4241
* cleanup dead code by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4271
* unbreak ci lighthouse by adhami3310 in https://github.com/reflex-dev/reflex/pull/4273
* resync steps with task advance by adhami3310 in https://github.com/reflex-dev/reflex/pull/4275
* [ENG-3961] move "warn_if_too_large" logic into BaseState by masenf in https://github.com/reflex-dev/reflex/pull/4284
* raise error when get package manager is not found by adhami3310 in https://github.com/reflex-dev/reflex/pull/4289
* better missing system package message by adhami3310 in https://github.com/reflex-dev/reflex/pull/4306
* move check of path to only check name by adhami3310 in https://github.com/reflex-dev/reflex/pull/4299
* special case field in _isinstance by adhami3310 in https://github.com/reflex-dev/reflex/pull/4298
* bypass pydantic runtime validation for state init by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4256
* add codeowners by Kastier1 in https://github.com/reflex-dev/reflex/pull/4312
* stop ignoring some lint rules by Lendemor in https://github.com/reflex-dev/reflex/pull/4311
* mark var methods as private by adhami3310 in https://github.com/reflex-dev/reflex/pull/4319
* test_exception_handlers: add test case that triggers ErrorBoundary by masenf in https://github.com/reflex-dev/reflex/pull/4327

New Contributors
* lb803 made their first contribution in https://github.com/reflex-dev/reflex/pull/4249
* grahamannett made their first contribution in https://github.com/reflex-dev/reflex/pull/4291

**Full Changelog**: https://github.com/reflex-dev/reflex/compare/v0.6.4...v0.6.5

0.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

<details>

<summary>See Example</summary>

This example allows for near drop-in support for working with SQLAlchemy `DeclarativeBase` models and will likely be included in a future release:

python
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


</details>

* make var system expandable by adhami3310 in https://github.com/reflex-dev/reflex/pull/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

python
rx.config(
...
gunicorn_max_requests=50
...
)


Experimental Shiki Codeblock

python
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 https://github.com/reflex-dev/reflex/pull/4030

`dotenv` support added

To use this feature, you must install `python-dotenv` separately from reflex.

python
import reflex as rx

config = rx.Config(
app_name="mycoolapp",
env_file=".env",
)


* HOS-93: add support for .env file by Kastier1 in https://github.com/reflex-dev/reflex/pull/4219
* make python-dotenv optional by Lendemor in https://github.com/reflex-dev/reflex/pull/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.

<details>

<summary>See Example</summary>

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.

python
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",
),
)


</details>

* implement rx dynamic by adhami3310 in https://github.com/reflex-dev/reflex/pull/4195

Improvements

Better Type Hinting for Built in Components
* add type hinting to error boundary by adhami3310 in https://github.com/reflex-dev/reflex/pull/4182
* add event types to suneditor by adhami3310 in https://github.com/reflex-dev/reflex/pull/4209
* Add type hinting to dataeditor events by adhami3310 in https://github.com/reflex-dev/reflex/pull/4210
* Add on progress typing to react player by adhami3310 in https://github.com/reflex-dev/reflex/pull/4211
* add additional typing for calling events by adhami3310 in https://github.com/reflex-dev/reflex/pull/4218

Other Improvements
* allow setting run mode via env, add helpers to determine it by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4168
* Raise TypeError when `ComputedVar.__init__` gets bad kwargs by masenf in https://github.com/reflex-dev/reflex/pull/4199
* move all environment variables to the same place by adhami3310 in https://github.com/reflex-dev/reflex/pull/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 https://github.com/reflex-dev/reflex/pull/4239

Bug Fixes
* use larger or equal for node version check by adhami3310 in https://github.com/reflex-dev/reflex/pull/4189
* check for none before returning which by adhami3310 in https://github.com/reflex-dev/reflex/pull/4187
* fix and test bug in config env loading by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4205
* fix inverted alembic file check by adhami3310 in https://github.com/reflex-dev/reflex/pull/4238
* fix: async default setters break setvar by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4169
* Fix 'enter_key_submit=True' on 'rx.text_area' by carrying custom_code on debounce by masenf in https://github.com/reflex-dev/reflex/pull/4142
* Handle props annotated as list/dict of EventHandler (4257)

Version Bumps
* upgrade node to latest lts by adhami3310 in https://github.com/reflex-dev/reflex/pull/4191
* versions bump before 0.6.4 by Lendemor in https://github.com/reflex-dev/reflex/pull/4208
* bump ruff to 0.7.0 by Lendemor in https://github.com/reflex-dev/reflex/pull/4213

Other Changes
* pin AppHarness tests to ubuntu-22.04 runner by masenf in https://github.com/reflex-dev/reflex/pull/4173
* Remove demo command by Alek99 in https://github.com/reflex-dev/reflex/pull/4176
* move client storage classes to their own file by Lendemor in https://github.com/reflex-dev/reflex/pull/4216
* use $ syntax by adhami3310 in https://github.com/reflex-dev/reflex/pull/4237
* test for stateless apps by Lendemor in https://github.com/reflex-dev/reflex/pull/3816


**Full Changelog**: https://github.com/reflex-dev/reflex/compare/v0.6.3.post1...v0.6.4

0.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**: https://github.com/reflex-dev/reflex/compare/v0.6.3...v0.6.3.post1

0.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).

* Support aria and data props by masenf in https://github.com/reflex-dev/reflex/pull/4149

Reflex Code

python
rx.icon_button("save", aria_label="Save Changes", data_test="arbitrary data")


Generated Output

html
<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.

python
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 https://github.com/reflex-dev/reflex/pull/4066
* add type hinting to events by adhami3310 in https://github.com/reflex-dev/reflex/pull/4145
* Fix runtime error on python 3.11.0 (4197)
* fix pyi for untyped event handlers (4186)
* Arbitrary arg access two levels deep for untyped handler (4180)

Other Improvements

* Optimize StateManagerDisk by masenf in https://github.com/reflex-dev/reflex/pull/4056
* Reduce pickle size by masenf in https://github.com/reflex-dev/reflex/pull/4063
* fail safely when pickling by adhami3310 in https://github.com/reflex-dev/reflex/pull/4085
* First use environment variable as npm registry by ruhz3 in https://github.com/reflex-dev/reflex/pull/4082
* let users pick state manager mode by Lendemor in https://github.com/reflex-dev/reflex/pull/4041
* disk is memory is disk (4185)
* When REDIS_URL is set, use redis, regardless of config preference. (4196)
* Allow setting a different invocation function for EventChain by masenf in https://github.com/reflex-dev/reflex/pull/4160

Bug Fixes
* convert literal type to its variants by adhami3310 in https://github.com/reflex-dev/reflex/pull/4062
* catch CancelledError in lifespan hack for windows by Lendemor in https://github.com/reflex-dev/reflex/pull/4083
* Get default for backend var defined in mixin by masenf in https://github.com/reflex-dev/reflex/pull/4060
* [ENG-3903] bundle next link in window by adhami3310 in https://github.com/reflex-dev/reflex/pull/4064
* misc var improvements by adhami3310 in https://github.com/reflex-dev/reflex/pull/4068
* [ENG-2287] Avoid fetching same state from redis multiple times by masenf in https://github.com/reflex-dev/reflex/pull/4055
* reset backend vars in state.reset() by adhami3310 in https://github.com/reflex-dev/reflex/pull/4087
* fix custom component init by Lendemor in https://github.com/reflex-dev/reflex/pull/4123
* use system npm when REFLEX_USE_SYSTEM_NODE is passed by adhami3310 in https://github.com/reflex-dev/reflex/pull/4133
* Remove wrong event handlers by adhami3310 in https://github.com/reflex-dev/reflex/pull/4136
* fix: Determine str type from value. by abulvenz in https://github.com/reflex-dev/reflex/pull/4143
* remove dictify from state dict by adhami3310 in https://github.com/reflex-dev/reflex/pull/4141
* catch ValueError("I/O operation on closed file.") if frontend crashes by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4150
* fix union types for vars by adhami3310 in https://github.com/reflex-dev/reflex/pull/4152
* Change bun link by adhami3310 in https://github.com/reflex-dev/reflex/pull/4162
* change bun install link to main by adhami3310 in https://github.com/reflex-dev/reflex/pull/4164
* only load json if it's *not* empty by adhami3310 in https://github.com/reflex-dev/reflex/pull/4165
* Handle rx.State subclasses defined in function by masenf in https://github.com/reflex-dev/reflex/pull/4129
* Do not auto-determine generic args if already supplied by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4148
* unionize base var fields types by adhami3310 in https://github.com/reflex-dev/reflex/pull/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 https://github.com/reflex-dev/reflex/pull/4050
* upgrade default node to current lts by adhami3310 in https://github.com/reflex-dev/reflex/pull/4086
* update ruff to latest version by Lendemor in https://github.com/reflex-dev/reflex/pull/4081
* Revert Markdown-related frontend dep bumps by masenf in https://github.com/reflex-dev/reflex/pull/4088
* pin AppHarness tests to ubuntu-22.04 runner (4173)

Documentation
* default props comment for CartesianAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4127
* default props comment for CartesianGrid by carlosabadia in https://github.com/reflex-dev/reflex/pull/4126
* default props comment for ReferenceLine by carlosabadia in https://github.com/reflex-dev/reflex/pull/4122
* default props comment for ReferenceArea by carlosabadia in https://github.com/reflex-dev/reflex/pull/4124
* default props comment for Scatter by carlosabadia in https://github.com/reflex-dev/reflex/pull/4118
* default props comment for Area by carlosabadia in https://github.com/reflex-dev/reflex/pull/4115
* default props comment for Line by carlosabadia in https://github.com/reflex-dev/reflex/pull/4117
* default props comment for Bar by carlosabadia in https://github.com/reflex-dev/reflex/pull/4116
* default props comment for Brush by carlosabadia in https://github.com/reflex-dev/reflex/pull/4113
* default props comment for ZAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4112
* default props comment for YAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4111
* default props comment for XAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4110
* default props comment for Legend by carlosabadia in https://github.com/reflex-dev/reflex/pull/4100
* default props comment for PolarAngleAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4106
* default props comment for LabelList by carlosabadia in https://github.com/reflex-dev/reflex/pull/4102
* default props comment for treemap by carlosabadia in https://github.com/reflex-dev/reflex/pull/4098
* default props comment for ResponsiveContainer by carlosabadia in https://github.com/reflex-dev/reflex/pull/4099
* default props comment for scatterchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4096
* default props comment for radarchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4094
* default props comment for radialbarchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4095
* default props comment for barchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4092
* default props comment for composedchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4093
* areachart default value for base_value by carlosabadia in https://github.com/reflex-dev/reflex/pull/4090
* default props comment for categoricalchartbase by carlosabadia in https://github.com/reflex-dev/reflex/pull/4091
* default props comment for PolarGrid by carlosabadia in https://github.com/reflex-dev/reflex/pull/4107
* default props comment for Reference by carlosabadia in https://github.com/reflex-dev/reflex/pull/4121
* default props comment for funnelchart by carlosabadia in https://github.com/reflex-dev/reflex/pull/4097
* default props comment for Radar by carlosabadia in https://github.com/reflex-dev/reflex/pull/4104
* Add Vietnamese README docs by nguyenmphu in https://github.com/reflex-dev/reflex/pull/4138
* fix docstring by benedikt-bartscher in https://github.com/reflex-dev/reflex/pull/4140
* default props comment for Grid by carlosabadia in https://github.com/reflex-dev/reflex/pull/4125
* default props comment for Funnel by carlosabadia in https://github.com/reflex-dev/reflex/pull/4119
* default props comment for ErrorBar by carlosabadia in https://github.com/reflex-dev/reflex/pull/4120
* default props comment for Cartesian by carlosabadia in https://github.com/reflex-dev/reflex/pull/4114
* default props comment for RadialBar by carlosabadia in https://github.com/reflex-dev/reflex/pull/4105
* default props comment for PolarRadiusAxis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4108
* default props comment for Pie by carlosabadia in https://github.com/reflex-dev/reflex/pull/4103
* default props comment for Axis by carlosabadia in https://github.com/reflex-dev/reflex/pull/4109

Other Changes
* test_dynamic_routes: log on_loads and poll for 60 seconds on order by masenf in https://github.com/reflex-dev/reflex/pull/4089
* only run macOS job on merge by Lendemor in https://github.com/reflex-dev/reflex/pull/4139
* Change the defalut direction of radio group by Manojvbhat in https://github.com/reflex-dev/reflex/pull/4146

New Contributors
* nguyenmphu made their first contribution in https://github.com/reflex-dev/reflex/pull/4138
* ruhz3 made their first contribution in https://github.com/reflex-dev/reflex/pull/4082
* Manojvbhat made their first contribution in https://github.com/reflex-dev/reflex/pull/4146

**Full Changelog**: https://github.com/reflex-dev/reflex/compare/v0.6.2...v0.6.3

Page 1 of 14

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.