github reflex-dev/reflex v0.11.0a2

pre-release50 minutes ago

Breaking Changes

  • Calling an rx.App instance (app()) returns a plain ASGI callable instead of a Starlette app, so the result no longer has add_middleware, routes or mount. Add Starlette middleware and routes with api_transformer instead. (#7624)
  • rx.ModelRegistry.register(Base) is now optional: until a base is registered, reflex db and the alembic command line migrate the tables of every DeclarativeBase subclass defined at module level or in a class body of a module the app imports. A base meant for another database, or one defined by an installed library, then gets create_table in the db_url migrations; register the bases of db_url with rx.ModelRegistry.register(Base) to leave the others out. An autogenerated revision that drops tables now logs a warning naming them. (#7797)

Features

  • rx.foreach now warns at compile time when an item with lifecycle events (on_mount, on_unmount) or hooks of its own is keyed by its index, which is the default. After an item is removed, its on_unmount runs for the item at the last position; set a unique, stable key, such as key=item.id, or key=item for a list of unique strings, on the component the render function returns. (#7820)

Bug Fixes

  • With REFLEX_OPLOCK_ENABLED and several production backend workers, an event waiting for a token's lock on one worker no longer stalls for about a tenth of the lock expiration behind another worker's lease. (#7795)
  • In production, Granian now replaces a backend worker that dies (for example one killed by the OOM killer) instead of stopping the whole server; if a replaced worker dies again within a few seconds, the server still exits. Set GRANIAN_RESPAWN_FAILED_WORKERS=false to keep the old fail-fast behavior, for example when a process supervisor restarts the server. (#7803)
  • The deprecated rx._x.client_state now requires a name that is an ASCII identifier without $, as rx.client_state does, and an app whose pages declare one client state name with two different defaults fails to compile with an error naming both declarations. (#7804)
  • Write .web/package.json, and the copy kept in reflex.lock/package.json, in the layout bun uses, so the kept file no longer flips between formats and produces whitespace-only diffs. (#7812)
  • reflex db makemigrations refuses to add a NOT NULL column whose only default is a dataclass default_factory (mapped_column(default_factory=...) on a MappedAsDataclass model) and names the column, instead of writing a revision that fails on a table with rows. Give the column a server_default, a literal default=, or make it nullable. (#7815)

Don't miss a new reflex release

NewReleases is sending notifications on new releases.