Skip to content

Releases: reflex-dev/reflex

v0.4.6

01 Apr 23:49
5c8d5e5
Compare
Choose a tag to compare

Known Issues

  • Unhandled runtime error when navigating between pages in a stateless app.

This Release was Airdropped from 30000' over Nevada πŸͺ‚

IMG_2840

Breaking Changes

Use dill instead of cloudpickle

In reflex-0.4.6, existing states persisted in redis are not compatible. Redis should be cleared and existing states/sessions discarded after upgrading.

  • [REF-2089] Use dill instead of cloudpickle for serialization by @masenf in #2922

New Features

reflex component share CLI

Simplify sharing of custom 3rd party components to the Reflex Component Gallery.

  • [REF-2168] Add share options to custom component commands by @martinxu9 in #2883

rx.ComponentState

An easy way to define per-component State.

import reflex as rx

class CounterButton(rx.ComponentState):
    count: int

    def increment(self):
        self.count += 1

    def decrement(self):
        self.count -= 1

    @classmethod
    def get_component(cls, *children, **props):
        return rx.button(
            f"Counter {cls.count}",
            on_click=cls.increment,
            on_context_menu=cls.decrement.prevent_default,
        )

counter_button = CounterButton.create

@rx.page()
def index():
    return rx.vstack(
        *[counter_button() for _ in range(10)]
    )

app = rx.App()
  • [REF-2265] ComponentState: scaffold for copying State per Component instance by @masenf in #2923

Automatically Select Next Available Port

When the configured port is not available, automatically select the next sequential port until one is available

Expanding Textarea

New props on rx.el.textarea and rx.text_area allow the field to expand to match content and submit the form when Enter is pressed (shift+enter to create a new line)

  • textarea: expose auto_height and enter_key_submit props by @masenf in #2884

rx.scroll_to event

Scroll the viewpoint to show a given element by ID.

Improvements

Simplify Component Wrapping API

[REF-2272] Support declaring EventHandlers directly in component by @martinxu9 in #2952

Props typed as rx.EventHandler can be used to define event triggers without overriding get_event_triggers method. The argument of the type specifies the JS to Python mapping: on_click: rx.EventTrigger[lambda e: [e]].

generate pyi files when building/publishing 3rd party component by @Lendemor in #2945

Third-party components will now have .pyi files generated for them to improve IDE completion, similar to the built in Reflex components.

Updated Lucide Icons

The latest icons available on https://lucide.dev are now usable in Reflex. Some icon names have changed, these will print a deprecation warning pointing to the new name. The old names will be removed in 0.5.0.

Loosen Requirement Pins

Reflex is now compatible with a wider range of dependencies. Notably, it can be used with packages that depend on Pydantic v2 (although the framework itself is still using v1).

Note: due to a regression in recent uvicorn versions, that dep will remain pinned as it was in 0.4.5.

Avoid content flicker when using State.is_hydrated

is_hydrated is set to False immediately when a navigation event starts, and is set back to True after all on_load events have executed. This avoids content flickering into view before a loading spinner is displayed when the spinner is conditional on the value of State.is_hydrated.

Additionally, the WiFi off connection error pulser is only displayed when connection errors are detected (before it was displayed whenever the page was not hydrated).

  • Set is_hydrated=False at route onChangeStart by @masenf in #2949

Miscellaneous

  • [REF-1982] state: Warn if redis state is "too big" by @masenf in #2868
  • use radix box instead of chakra one for responsive elements by @Lendemor in #2921
  • [REF-2229]Dedupe deprecation warnings by @ElijahAhianyo in #2871
  • fix hook order to use ref inside user hooks by @Lendemor in #2906
    • Ensure user-defined hooks can always access refs
  • [REF-2302] When a Var points to a model, prefer access to model fields. by @masenf in #2893

Bug Fixes

  • [REF-2117]:rx.color_mode_cond to work in f-strings by @ElijahAhianyo in #2775
  • Default to None if bun/fnm version is Invalid by @ElijahAhianyo in #2940
  • remove inheritance from Flex for list components by @Lendemor in #2936
    • Fix markdown rendering of lists
  • parse_args_spec: resolve annotations with typing.get_type_hints by @masenf in #2849
  • [REF-2219] Avoid refetching states that are already cached by @masenf in #2953
    • Fix issue affecting Cookie/LocalStorage values when substates contained computed vars
  • [REF-2306] Include twine in dependencies on pyproject.toml by @martinxu9 in #2895

Other Changes

New Contributors

Full Changelog: v0.4.5...v0.4.6

v0.4.5

20 Mar 20:04
ab7b856
Compare
Choose a tag to compare

New Features

Support SQLAlchemy Models Directly

Experimental Multi-process Compilation

Pass REFLEX_COMPILE_PROCESSES=0 to opt-in to multiprocess compile, which significantly improves compilation speed of large apps (Mac and Linux only).

  • [REF-2122] Opt-in multiprocess compile by @masenf in #2838

Improvements

Bug Fixes

  • [REF-2172] Add DECORATED_PAGES before compiling in thread by @masenf in #2841
    • Fix known regression with py3.8 and py3.9
  • Remove width prop from rx.select by @picklelo in #2835
    • HighLevelSelect: pass flex_shrink prop to SelectTrigger by @masenf in #2876
  • Get client_ip from asgi.scope by @masenf in #2808
    • router.session.client_ip more likely to be correct now
  • convert text inside list_item to span and set icon display to inline by @Lendemor in #2860

Other Changes

  • [REF-2086] Avoid "Warning: The path to the Node binary could not be found. by @masenf in #2803
  • telemetry refactor + unit tests by @Lendemor in #2786
    • When __REFLEX_SKIP_COMPILE == "yes" allow telemetry to fail by @masenf in #2881
  • Custom Component Request Template by @Alek99 in #2853
  • Benchmark with app harness by @ElijahAhianyo in #2774
  • Fix py3.8 integration test_var_operations.py by @masenf in #2858
  • Account for imports of @rx.memo components for frontend package installation by @masenf in #2863
  • [REF-2216] Warn if windows is used with py312 by @masenf in #2856
  • Separate get_hooks and get_hooks_internal for stable output by @masenf in #2710
  • [REF-2219] vars: set _was_touched when updating cached vars by @masenf in #2886

New Contributors

Full Changelog: v0.4.4...v0.4.5

v0.4.4

11 Mar 22:53
b219540
Compare
Choose a tag to compare

Known Issues

py3.8 and py3.9 using @rx.page with REDIS_URL set:

RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.

Breaking Changes

Component._get_vars signature change

Unlikely to affect most users; however the signature of Component._get_vars has changed to accept a new include_children parameter which should either be handled internally or passed to super()._get_vars if this function has been overridden in a custom component.

New signature

def _get_vars(self, include_children: bool = False) -> Iterator[Var]:

New Features

Expose lang and other attributes on <html> tag

rx.upload exposes on_drop event trigger

Trigger upload immediately after files are selected by passing an rx.upload_files-wrapped handler directly to on_drop trigger.

  • Expose on_drop event trigger for rx.upload component. by @masenf in #2766

rx.el.form supports on_submit event trigger

  • [REF-1368] Move common form functionality to rx.el.forms by @masenf in #2801

Improvements

Dependency Changes

Enable /_upload when get_upload_url is used

Previously, the rx.upload component was the only thing that resulted in the endpoint being enabled.

  • Mark Upload.is_used when calling get_upload_url by @masenf in #2765

Update docker-example for more realistic deployments

  • a simple dual port Dockerfile

  • compose.yaml providing a separate backend container and static frontend served with automatic TLS

    • Support volumes for data and uploaded files
  • compose.prod.yaml including postgres database and redis containers

  • app.Dockerfile for single container, single port deployment on a platform service like Render, Railway, and Google Cloud Run

  • docker-example overhaul by @masenf in #2690

  • Include app.Dockerfile for deploying to container hosting platform by @masenf in #2784

Improve "Stateless" app detection

Apps which import State, but do not actually use it are considered stateless.

Apps that use rx.State.router automatically work without defining a dummy substate.

Apps dynamically create state at runtime (#1877) correctly include used dynamic substates.

Better support for plain SQLAlchemy

reflex component CLI improvements

  • Build and publish in a single step

  • Improved custom component template

  • More comprehensive .gitignore

  • fix template for custom comp by @Lendemor in #2787

  • [REF-2141] Custom component command improvements by @martinxu9 in #2807

EventChain list syntax is undeprecated

It is now acceptable to pass a list of multiple EventHandler to an event trigger, such as on_click.

Bug Fixes

  • Fix Padding in Accordion component
  • Skip node install if version requirements are met
  • Fix infinite recursion when a substate named "state" has a computed var by @masenf in #2778
  • Fix /_upload 404 and missing on_load handlers in production deployment
    • app_module_for_backend: wait for _compile in prod mode by @masenf in #2760
  • [REF-2087] Better rx.progress styling integration with radix themes by @masenf in #2762
  • Updating initialize_gitignore() to avoid modifying the encoding of the .gitignore file by @cllatser in #2797
  • Fix tab freezing and crash when appearance="dark" and theme_panel=True
    • [REF-1994] ThemePanel: clear chakra-ui-color-mode key when using theme panel by @masenf in #2799
  • [REF-2098] Allow overlay Close components to have on_click handlers by @masenf in #2793

Other Changes

New Contributors

Full Changelog: v0.4.3...v0.4.4

v0.4.3

04 Mar 22:52
c314d7f
Compare
Choose a tag to compare

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

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

  • [REF-1988] API to Get instance of Arbitrary State class by @masenf in #2678

CLI for Creating and Publishing 3rd Party Components

Improvements

Allow accent as a valid choice in rx.color

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.

  • [REF-1741] Disallow routes with /api prefix by @masenf in #2711

rx.plotly now accepts arbitrary config prop

Computed Backend-only Vars

Connection Pulser While Websocket is Disconnected

Only show the "Connection Error" banner after a few failed reconnection attempts.

  • add pulser for connection + adjust condition for connnection_modal by @Lendemor in #2676

Reconnect Websocket in Stale Tabs

When a browser tab regains focus, automatically reconnect the websocket if it is disconnected.

Bug Fixes

Other Changes

New Contributors

Full Changelog: v0.4.2...v0.4.3

v0.4.2

26 Feb 20:05
b13a25c
Compare
Choose a tag to compare

New Features

Syncronize LocalStorage between tabs

Pass the new sync=True argument to rx.LocalStorage to enable changes on one tab to automatically update in other tabs.

  • feat: Synchronizing localStorage between tabs using browser events by @abulvenz in #2533

Improvements

Tuple type annotations are now respected index-wise

Substates are serialized individually

This allows apps with large state to only serialize and deserialize the parts of the state needed to handle a given event.

  • [REF-1885] Shard Substates when serializing to Redis by @masenf in #2574

Better Image Serialization

Improves mime type detection for more types of PIL Image objects.

Other Improvements

Bug Fixes

  • Fix SQLAlchemy list types by @benedikt-bartscher in #2668
  • [REF-2045] Implement reduce_ex for MutableProxy by @masenf in #2688
  • Fix for setting rx.theme(appearance="dark") (Note: dark mode does not work with rx.theme_panel)
    • Apply app theme color_mode/appearance as next-themes default by @masenf in #2654
  • rx.Upload can now contain children components that use State.

Accordion Issues

  • Fix Browser Warnings
  • Fix accordion not working with rx.foreach

Other Changes

New Contributors

v0.4.1

20 Feb 02:49
6384c62
Compare
Choose a tag to compare

Fix Windows Hot-reload

Improvements

Avoid Browser Error When Uploading

  • fix: File upload error after using rx.clear_selected_files by @abulvenz in #2666

Bug Fixes

  • [REF-1993] link: respect is_external prop and other attributes on A tag by @masenf in #2651

New Contributors

Full Changelog: v0.4.0...v0.4.1

v0.4.0

16 Feb 22:33
899e35e
Compare
Choose a tag to compare

See our blog post for more details on this release: https://reflex.dev/blog/2024-02-16-reflex-v0.4.0

Known Issues

Hot reload on windows does not seem to work (Under investigation)

Breaking Changes

Top-level Namespace is now Radix Components

See the latest Reflex documentation for complete information about the new components API.

Run reflex script keep-chakra to retain compatibility with 0.3.x apps.

This script will automatically update your app code to reference previous top-level namespace via rx.chakra.<x>

Some components are no longer available in the core library and must now be accessed via rx.chakra such as:

  • circular_progress
  • stat and stat_group
  • list (Use rx.unordered_list(list_style_type="none") instead)
  • pin_input
  • circle
  • button_group

Component Prop Changes

  • rx.progress no longer supports is_indeterminate
  • rx.slider: value is expected to be a list of numbers, one for each slider thumb. on_change will be called with a list of numbers, one for each slider thumb.
  • rx.vstack and rx.hstack no longer center content by default.
  • rx.icon uses Lucide tags (rx.chakra.icon for the previous tags)
  • spacing and size props accept radix scale, generally string integers, from "0" to "9".
    • To apply CSS units, use CSS props like gap, height, width, padding, etc.
  • type_, max_, and min_ props should be specified without the trailing underscore.

Radix Themes

Apply themes to the root rx.App component via the theme=rx.theme(...) prop. This will apply the theme to all radix components.

New Features

Upload Workflow Refactor

  • Set upload dir via environment variable REFLEX_UPLOADED_FILES_DIR, which defaults to ./uploaded_files.
  • Use rx.get_upload_dir() to access the upload directory from the backend.
  • Use rx.get_upload_url(filename) to get a link to the uploaded file in the frontend.

rx.download now accepts str or bytes for data argument

Allow users to download data directly from the backend without writing to an intermediate file.

All Changes

Read more

v0.3.10

06 Feb 00:38
f5f7dcc
Compare
Choose a tag to compare

New Features

Lucide Icons (rx.lucide.icon)

View all iconds available via rx.lucide.icon at https://lucide.dev/icons/.

In 0.4.0, these icons will become the default icon set exposed at rx.icon.

Customize Reflex Directory location

Set REFLEX_DIR environment variable to control where reflex will download and install supporting
tools like bun, fnm, and node.

Improvements

  • Tabs validate parent is proper tab container by @tankztz in #2463

Only expose /_upload when using Upload component

  • auto enable /_upload endpoint only if Upload component is used by @benedikt-bartscher in #2430
  • Move is_used to Upload component rather than UploadFilesProvider by @masenf in #2514

Better SQLAlchemy Interoperability

Faster .pyi Generation (internal)

Fast Compilation

Use multiprocessing to compile CPU-bound pages faster.

Bug Fixes

Radix

The team is currently stabilizing the new radix-ui integration in preparation for our forthcoming 0.4.0
release.

Other Changes

New Contributors

Full Changelog: v0.3.9...v0.3.10

v0.3.9

22 Jan 21:47
82ce265
Compare
Choose a tag to compare

New Features

Mixin Classes can now be used to augment State subclasses

Improvements

Bug fixes

Radix UI Preview

Other Changes

  • Update comments in template apps by @masenf in #2370
  • Get rid of compile in readme by @Alek99 in #2371
  • integration tests: disable windows builds for reflex-web by @masenf in #2417
  • Allow app harness tests to import State subclasses by @masenf in #2408

Full Changelog: v0.3.8...v0.3.9

v0.3.8

08 Jan 21:33
43a0867
Compare
Choose a tag to compare

Deprecations

app.compile() boilerplate is no longer required

New Features

rx.match construct

rx.match acts as a switch statement, mapping multiple values to components or props.

rx.button(
    State.mood,
    background_color=rx.match(
        State.mood,
        ("happy", "yellow"),
        ("sad", "blue"),
        ("angry", "red"),
        ("tickled", "pink"),
        "",  # last value provided is the default
    )
)

Add rx.time_picker component

Improvements

Bug Fixes

  • REF-1476/Create .web only after template selection by @ElijahAhianyo in #2288
  • Chakra input component type_ prop literal by @ElijahAhianyo in #2292
  • Bug fix: Export should only excludes assets folder if it's in the top level by @martinxu9 in #2308
  • fix tailwind for stateful components imported from utils by @Lendemor in #2328
  • Fix browser warning when rendering lists via rx.markdown
    • Avoid passing props to lists and list items by @masenf in #2326
  • fix editable property of columns being ignored in data_editor by @Lendemor in #2338
  • Allow tailwind to be completely disabled
    • [REF-1365] Radix + Tailwind Compatibility (and allow tailwind to be completely disabled) by @masenf in #2246
  • Handle VarData roundtrip when encoded value contains newline by @masenf in #2350

Radix UI Preview

Other

New Contributors

Full Changelog: v0.3.7...v0.3.8