Releases: reflex-dev/reflex
v0.3.3 [yanked]
New Features
Python 3.12 is now supported
Next.js upgrade from 13 to 14
Clear Form using reset_on_submit prop
You can use the reset_on_submit on a form to reset form values to their original states after submitting the form. Simply set the value to True.
rx.form(
rx.input(id="text", placeholder="text"),
rx.button("Submit", type_="submit"),
reset_on_submit=True,
)Forms support dynamic names.
-
Dynamic refs / ids don't really work but you can use dynamicΒ names instead
rx.form( rx.vstack( rx.input(name="name_input"), rx.hstack(rx.pin_input(length=4, name="pin_input")), rx.number_input(name="number_input"), rx.checkbox(name="bool_input"), rx.switch(name="bool_input2"), rx.slider(name="slider_input"), rx.range_slider(name="range_input"), rx.radio_group(["option1", "option2"], name="radio_input"), rx.select(["option1", "option2"], name="select_input"), rx.text_area(name="text_area_input"), rx.input( name="debounce_input", debounce_timeout=0, on_change=rx.console_log, ), rx.button("Submit", type_="submit"), ), ),
-
Use
rx.Var.range(similar to pythonβsrange) withrx.foreachto dynamically create form elements with dynamic names.rx.Var.range(v1, v2, step)takes in start, end and step values which should be integers orVarintegers.class State: grid: int = 4 def handle_submit(self, form_data: dict): print(form_data) rx.form( rx.responsive_grid( rx.foreach( rx.Var.range(State.grid), lambda i: rx.foreach( rx.Var.range(State.grid), lambda j: rx.input( name=f"grid_{i}_{j}", placeholder=f"grid {i} {j}", key=f"{i}_{j}", width="4em", ), ), ), columns=[State.grid], ), rx.button("Submit", type_="submit"), reset_on_submit=True, on_submit=State.handle_submit, ),
New form-based code should prefer to use the name attribute to avoid the overhead of using refs for no specific gain (unless focus or value setting is required).
Improvements
- Assume secure protocol (wss://) and no port If the frontend is being accessed via
HTTPSand theAPI_URLis eitherlocalhost,0.0.0.0or::and uses a non-secure protocol by @masenf in #2129 - Reduce Syntax highlighter footprint by @ElijahAhianyo in #2037
- Lazy import modules in reflex by @picklelo in #2144
Doc fixups
- fix: grammatical errors & typo in Spanish [readme.md](http://readme.md/) by @cllatser in #2139
- docs: remove duplicated content in [CONTRIBUTING.md](http://contributing.md/) by @Jaspreet-singh-1032 in #2152
- docs: revise typo in korean README and common CONTRIBUTING readme by @young-hun-jo in #2160
Bug Fixes
- fix an issue where some fields in
State.router.headerswere not getting updated by @Lendemor in #2133 - Resolve peer dependency conflict causing package-lock.json to relock on every run by @ElijahAhianyo in #2106
Other Changes
New Contributors
- @cllatser made their first contribution in #2130
- @Jaspreet-singh-1032 made their first contribution in #2152
- @young-hun-jo made their first contribution in #2160
Full Changelog: v0.3.2...0.3.3
v0.3.2
Thank you to our wonderful users and contributors! π π
New Features
Expose stop_propagation and prevent_default on Event Handlers
When an event trigger should not propagate to DOM elements nested below it use .stop_propagation.
When an event action should override the browser default (like following a link), use .prevent_default.
Each of these "event actions" will trigger the frontend to call the corresponding method on the DOM event associated with the event trigger. Both actions may be applied to the same event handler.
- Expose DOM event actions on EventHandler, EventSpec, and EventChain (stopPropagation) by @masenf in #1891
- Do not stop prop is there is no prop to stop by @masenf in #2116
Gunicorn Worker Class
The gunicorn_worker_class may be specified in rxconfig.py to configure low-level uvicorn settings when running in prod mode. See example in dicussion #2070.
Components can be passed as props
Components can now accept props with type Var[Component], which allows for greater customization of components and greater flexibility when wrapping third-party components.
This only works for static components passed at compile-time. Components cannot be used in a State Var.
Github Codespaces
Creating a codespace from the reflex repo is now supported. Be sure to open the Backend URL in the browser first (or mark the port as Public) to allow the frontend to access the backend via websocket.
Improvements
Add orientation prop to rx.stepper
Add column resize for data editor
Doc fixups
- fix: Typo in README.md by @debajoti in #2069
- fix: Grammatical error & typo in CONTRIBUTING.md by @debajoti in #2072
- docs: fixed wrapping react link by @Shreyas0410 in #2097
- Added links for Github issues and contributing.md file by @Sentious in #2076
- DALL E and API docs by @krishvsoni in #2082
- Typos fixed in multiple files by @SandeshPyakurel in #2090
- Fix readme links by @picklelo in #2118
Template Improvements
- base: expand template content to right edge of screen by @masenf in #2104
- Use blank template as default by @picklelo in #2109
- Prompt for template on reflex init by @picklelo in #2122
Hosting Service CLI
- [REF-1042] Hosting CLI: check the user selected app name by @martinxu9 in #2102
- Hosting CLI: use http endpoint to return deploy milestones by @martinxu9 in #2085
Other Improvements
- pyproject.toml: bump typer to 0.9.0 by @masenf in #2068
- cleanup dataeditor js code and hooks by @Lendemor in #2095
- rx.call_script callback needs to await promises by @masenf in #2121
Bug Fixes
- fix docker example by @dodeca-6-tope in #2086
- fix portal when using multiple dataeditor by @Lendemor in #2094
- make download work for state vars by @Lendemor in #2092
- Set unique index vars in rx.foreach by @picklelo in #2126
README Translations
- Added Spanish Readme by @bryan-trz in #2028
New Contributors
- @debajoti made their first contribution in #2069
- @dodeca-6-tope made their first contribution in #2086
- @Shreyas0410 made their first contribution in #2097
- @Sentious made their first contribution in #2076
- @krishvsoni made their first contribution in #2082
- @SandeshPyakurel made their first contribution in #2090
- @shu-qian made their first contribution in #2089
- @bryan-trz made their first contribution in #2028
Full Changelog: v0.3.1...v0.3.2
v0.3.1
v0.3.0
Breaking Changes
Drop Python 3.7 Support
Victory charts are completely removed in this release.
Graph and chart functionailty has been replaced by Recharts, see the docs for more examples.
- Remove victory charts by @ElijahAhianyo in #1945
Removal of Deprecated Browser Storage API
- Deprecate rx.get_cookies by @ElijahAhianyo in #1961
- Remove 0.3.0 deprecated features by @ElijahAhianyo in #1947
rx.Var Fields are Renamed
Most users are not interacting the Var class directly, but if you are, the following fields have been renamed:
name->_var_nametype_->_var_typestate->_var_stateis_local->_var_is_localis_string->_var_is_string
This allows rx.Base and rx.Model classes using these field names to be accessed through State vars.
Prop Values are Validated
Each component prop now defines values as typing.Literal, which has two effects:
- In IDEs, the allowed values for a field will be prominently displayed.
- When compiling, invalid literal values for props will raise an exception.
The following code will now raise ValueError
rx.button("Foo", color_scheme="silly")ValueError: prop value for color_scheme of the `Button` component should be one of the following: none,gray,red,orange,yellow,green,teal,blue,cyan,purple,pink,whiteAlpha,blackAlpha,linkedin,facebook,messenger,whatsapp,twitter,telegram. Got 'silly' insteadIf you need to pass an unrecognized prop value, you can wrap it in an rx.Var.
rx.button("Foo", color_scheme=rx.Var.create("silly"))- Props as Literals by @ElijahAhianyo in #1921
New Features
New Base Template
When running reflex init in a new directory, a multi-page template will be deployed instead of the Welcome to Reflex page. This provides a better starting point for more complex apps.
Use reflex init --template blank to generate a new app with the previous template.
- Added base template + improve templating code by @Alek99 in #1937
- [REF-876] Update base template styles by @masenf in #2022
- Update base template styling by @picklelo in #2050
- Update base template by @picklelo in #2027
New Component: rx.data_editor
Based on the Glide Data Grid, the new rx.data_editor component supports in place editing of data tables and is more feature rich than the existing rx.data_table component.
See the docs for more examples and details.
(Note: pandas dataframe is not currently supported, but will be coming soon)
- Lendemor/add datagrid editor by @Lendemor in #1941
- fix editable column and theme casting by @Lendemor in #2051
State.router
The State.router property provides access to the current page's router data in a way that can be accessed from both the frontend and the backend.
Previous State.get_current_page(), State.get_query_params(), and others are now deprecated.
New component: rx.moment
Simple date/time formatting on the frontend, and provides an event trigger that can be fired peridically from the frontend.
- Wrap Moment Component by @Lendemor in #1994
- react-moment is used under the hood.
Reflex Hosting Preview
This release includes support for the new Reflex Hosting service, currently in closed testing, please reach out on Discord for more information.
- [REF-99] Add first version of CLI for hosting service by @martinxu9 in #1810
- [reflex hosting] clean up tmp dir for storing zip archives by @jackie-pc in #2021
- CLI switch to prod server by @martinxu9 in #2016
- CLI improvements by @martinxu9 in #2026
- add region check upfront when user deploys interactively by @martinxu9 in #2030
- CLI will not set auto/stop setting for deployment by @martinxu9 in #2040
- Add back build log command to CLI by @martinxu9 in #2053
Demo App
Running reflex demo will now open a demo app based on the new base template showing some reflex features.
- Tom/template demo app by @tgberkeley in #2046
- Add CLI demo command by @Alek99 in #2044
- Use demo app for reflex demo command by @picklelo in #2048
- Update demo command to open demo.reflex.run by @picklelo in #2059
(Currently using a remotely hosted version of the app, but subsequent release will run the demo app locally.)
Radix Themes Preview
Reflex is moving away from Chakra-UI component to Radix-UI. And some of the new components are available in this release for testing in the reflex.components.radix.themes module. More details to follow.
- [REF-668] Wrap MyApp with radix Theme component by @masenf in #1867
- [REF-938] Fix up radix themes issues by @masenf in #2002
Improvements
Automatic API_URL
Most users will not have to explicitly set API_URL unless their frontend and backend are running on different hosts or via a load balancer.
When the default API_URL of http://localhost:{backend_port} is used, and the frontend is not being accessed on localhost, assume that the backend and frontend are on the same host.
Support for Static Sites
Do not display the connection error banner or attempt to connect to the backend if the app does not use State.
- No state No Websocket by @ElijahAhianyo in #1950
- Remove Default state by @ElijahAhianyo in #1978
Improve reflex export
- Support exporting to zip archives to a dir that is not cwd (to be use by hosting cli) by @jackie-pc in #2005
- [reflex export] backend.zip excludes dirs that look like venv dirs by @jackie-pc in #2009
Access Relationship Attributes on rx.Model
Autogenerate missing requirements.txt
An app must have a requirements.txt to be deployed via the hosting service, so Reflex will create one based on top-level packages in the environment where it is running.
Support callback in rx.call_script
When running arbitrary script, it is now possible to pass the result back to an Event Handler. See the updated docs for more examples.
Miscellaneous
- Warn when computed vars raise an exception by @masenf in #1939
- Stop double compiles in dev mode by @picklelo in #1990
- Improve Event handler Error message by @ElijahAhianyo in #2019
- Relax wrapt dependency for tensorflow compatibility by @masenf in #2001
Bug Fixes
- Fix custom components special props by @picklelo in #1956
- Fix charts not displaying without specifying width and height
- Fix Cookie and LocalStorage values being reset on navigation
- Bug: changing type of playing by @Billa05 in #1986
- Rehydrate client storage after rx.remove_local_storage and rx.remove_cookies by @ElijahAhianyo in #1998
- multi_select somewhat usable by @masenf in #1861
- fix fnm version check by @Lendemor in #2014
- Resolve npm path and fnm path on Windows by @masenf in #2015
- Radix Themes style notation fix by @ElijahAhianyo in #2025
- Generate state delta from processed state instance by @masenf in ...
v0.2.9
Breaking Changes
rx.constants module refactored
- Many names have changed for better organization and namespacing of the growing number of constant values.
rx.constantsis not really a public API, but some existing code may have been accessing values in this module.
- code cleanup (split constants into a folder) by @Lendemor in #1866
New Features
Core Graphing Library is now Recharts
The API for rendering charts and graphs has changed.
- See the docs for examples and more information.
- Victory charts are deprecated and will be removed in a subsequent release.
rx.datais no longer used.
- #1878
Run Arbitrary Javascript from Event Handler
Redirect into New Window
return rx.redirect("https://google.com", external=True)to open page in new tab/window- allow external link for redirect by @Lendemor in #1902
HTML Editor Component
Improvements
- Allow arbitrary Reflex components to map to markdown tags for more customizable styling.
- Include scripts in
<head>for every page by settinghead_componentsprop inrx.App - Adding Missing Props to
button,button_group, andcircular_progress- Add button spinner_placement prop by @ElijahAhianyo in #1871
- Button Group variant and size props by @ElijahAhianyo in #1873
- circular_progress cleanup: size, thickness, label by @masenf in #1879
- Add
Readme.mdfor turkish language by @09u2h4n in #1922 - Pin frontend package versions by @picklelo in #1920
- More reliable deploys without bringing in unexpected upstream changes
Bug Fixes
- component:
importsoverride_get_dependencies_importsby @masenf in #1859 - Fix regression where
rx.tablestopped working with state Var- rx.table
__bool__regression fix by @ElijahAhianyo in #1828
- rx.table
MutableProxyfixes when accessinglist,dict, orsetvars on a State- fix rx.image src not working with state by @Lendemor in #1915
- fix menu items= API by @Lendemor in #1905
Other Changes
- Bump to v0.2.8 by @picklelo in #1855
- Format event handlers not in importable modules by @picklelo in #1875
- Add a placeholder timeout to GitHub Actions unit tests by @jackwcodes in #1897
- test_state: assert popped value is the actual value by @masenf in #1906
- Deprecate set_cookie and set_local_storage by @ElijahAhianyo in #1917
- Add forward slash to local JS import by @picklelo in #1924
- Update Deprecations by @ElijahAhianyo in #1927
New Contributors
Full Changelog: v0.2.8...v0.3.0
v0.2.8
β¨ This release is made possible in part by users like YOU! β¨
Breaking Changes
CopyToClipboard component has been removed.
Use the rx.set_clipboard special event instead.
New Features
get_event_triggers API
The new Component.get_event_triggers API combines the old get_triggers and get_controlled_triggers methods into a unified API (the previous methods will continue to work in 0.2.8, but wrapped components should move to the new API).
The new API is more flexible, providing control over handler and trigger argument mapping. The method is expected to return a dictionary of callables. The keys are the names of the triggers in the react component. The values are callables whose signature defines the javascript trigger signature and the return value is a list of args that will be passed to the python EventHandler function.
This allows wrapping of components that accept non-standard event handler functions. Typically a lambda is used to map arguments, but a regular function with type annotations can also be used to enable extended Var operations like indexing.
For example, the FormSelect component uses a non-standard signature for on_change, this can now be accomodated in the new API.
class FormSelect(rx.Component):
library = "@patternfly/react-core"
tag = "FormSelect"
def get_event_triggers(self) -> Dict[str, Any]:
return {
EventTriggers.ON_CHANGE: lambda _e, value: [value],
}rx.download special event
The new download event prompts the frontend browser for file download.
It can be used directly as an event trigger:
rx.button("Download file", on_click=rx.download("/uri/for/file.extension", "target_file.extension")Or it can be yielded from a backend event handler:
def export_data(self):
...
# do export logic here and write to filepath
# then
yield rx.download(filepath, filename)Register Serializers for Custom Types
A one-arg callable in a Reflex app or component module with @rx.serializer decorator will be considered a serializer for the type of its argument. This allows arbitrary types used on the backend to be accessed on the frontend, as long as there is a serializer defined that returns a JSON serializable value.
For example, the following code is used to serialize plotly Figure objects.
import json
from plotly.graph_objects import Figure
from plotly.io import to_json
@rx.serializer
def serialize_figure(figure: Figure) -> list:
return json.loads(str(to_json(figure)))["data"]Background Task Event Handlers that do not block other Events
An async EventHandler function in a State that is decorated with @rx.background is considered a "Background Task". When triggered by the frontend or chained from another event handler, it will spawn a long running task that will NOT block other EventHandlers from running.
There are three main differences from a normal EventHandler to be aware of:
- Background Task must be
async - Background Task cannot directly modify state values and state values may be stale if other events have modified the state since the task started running.
- Only read or write state vars inside an
async with selfcontext block, where exclusive access to the latest state is guaranteed.
- Only read or write state vars inside an
- Background Task cannot be directly called from another event handler.
- Must
yieldorreturnthe background task to chain it from another handler.
- Must
class State(rx.State):
counter: int = 0
@rx.background
async def bg_task(self):
for ix in range(10):
async with self:
# state mutation is only allowed inside context block
self.counter += 1
# await long operations outside the context to avoid blocking
await asyncio.sleep(0.5)Full documentation for this feature is still being developed. Please post comments regarding background tasks on the discussion thread.
- rx.background and StateManager.modify_state provides safe exclusive access to state by @masenf in #1676
Improvements
Support Reactivity for rx.Base fields
Modifying fields on an rx.Base instance will trigger updates in the state without having to reassign them. This also applies when working with fields that are container types such as list and dict.
Better Error Messages
- Style props with Callable Values by @ElijahAhianyo in #1751
- Type Validation for Var Operations and Enhanced Compatibility by @ElijahAhianyo in #1674
Usability
- Allow underscores in routes by @ElijahAhianyo in #1713
- Implemented color_scheme for Tabs Component by @raven-black-dream in #1792
- Simplify base rxconfig by @picklelo in #1821
- Number input float by @raven-black-dream in #1817
- Support custom styling for code in markdown by @picklelo in #1844
- add option to disable Tailwind by @ElijahAhianyo in #1842
Bug Fixes
- added check to remove local import starting from . by @wassafshahzad in #1807
- exec: print the URL, not the address the server binds to by @masenf in #1846
Minor Changes and Fixups
- use actions/checkout@v4 by @masenf in #1768
- Bump version to 0.2.7 by @picklelo in #1782
- check pyi generations are up to date by @jackie-pc in #1786
- supply default for rx.Model PK for both DB and python to work by @martinxu9 in #1788
- move dynamic imports to dedicated method by @Lendemor in #1785
- removed is_read_only from select by @wassafshahzad in #1799
- numberinput: check
_id is not Noneto avoid Var truthiness warning by @masenf in #1806 - Remove deprecated route decorator by @ElijahAhianyo in #1815
- Move custom styles to root App file(_app.js) by @ElijahAhianyo in #1764
- Disable metrics in CI by @picklelo in #1822
- Remove extra imports from rx.markdown by @picklelo in #1837
- Prevent Substate class shadowing by @ElijahAhianyo in #1827
- pyproject.toml: add
packagingto dep list by @masenf in #1839 - state: implement copy and deepcopy for MutableProxy by @masenf in #1845
- allow for non-installable imports by @Lendemor in #1843
- Format component as React string by @picklelo in #1848
- use jinja2 to render package.json by @Lendemor in #1849
- StateProxy rebinds functools.partial and methods that are bound to the proxied State by @masenf in #1853
New Contributors
- @raven-black-dream made their first contribution in #1792
Full Changelog: v0.2.7...v0.2.8
v0.2.7
πΒ Thanks to our supportive community and helpful contributors! πͺ
Breaking Changes
Default Websocket Endpoint is now /_event #1542
Upload endpoint also moved to /_upload.
Any reverse proxy configurations that were explicitly forwarding /event and /upload to the backend server should be updated to use the new endpoints.
- renamed reserved endpoints of Reflex by @Lendemor in #1542
- Caddyfile: reflex uses
/_eventand/_uploadnow by @masenf in #1726
App kwarg connect_error_component is removed.
Use overlay_component instead. (#1379)
New Features
Client-side Storage integrated with State #1629
- Allow
rx.LocalStorageandrx.Cookietype vars in a State class that are automatically persisted in the client browser when modified on the backend. - These values can be used in frontend or backend code just like any other state Var.
class State(rx.State):
my_token: rx.LocalStorage = ""
my_hour_cookie: rx.Cookie = rx.Cookie("initial", max_age=3600)
def set_token(self):
self.my_token = str(uuid.uuid4())
def update_cookie(self):
if self.my_hour_cookie == "initial":
self.my_hour_cookie = "updated"Implement on_mount and on_unmount for all components #1636
These new event handlers, present on all components, tie into Reactβs useEffect hook and are used to trigger backend events needed to initialize a component when it loaded in a page.
Note: on_mount will fire twice in dev mode due to the use of Reactβs StrictMode.
Note: on_mount will not fire for page navigation events between different params of the same dynamic route, since the page itself does not get reloaded so no remount occurs. For navigation events, see on_load argument of app.add_page.
FNM is now used to install nodejs on POSIX platforms
by @ElijahAhianyo in #1606 #1701
frontend_packages are automatically determined #1607
frontend_packagesare inferred based on thelibraryprop of a wrapped component, instead of having to specify them manually in therxconfig.pyfile.- The
libraryprop may now include a version pin, like **library =** "gridjs-react@^6.0.1" - The
package.jsonlist of frontend dependencies only includes components that are actually used in the app, which decreases bundle size. - To include additional dependencies used by a component, specify them in the new
lib_dependenciesprop of the wrapped component.
Per-component prop autocompletion for IDEs #1708
Generated .pyi files provide better function signatures for component create methods, enumerating most recognized props.
Further enhancements will be supplied in a future release to include per-prop documentation and improved signatures for event handlers.
Support Breakpoints in VSCode and PyCharm #1653
- Breakpoints set in the IDE will be respected when running the project in dev mode. See DEBUGGING.md for an example.
Expose basePath configuration option #1724
Support running multiple reflex apps from the same domain by changing the basePath prefix that the frontend uses (by @nevdelap).
Improvements
- Validate component children by @ElijahAhianyo in #1647
- Refactor zipping in
reflex exportby @martinxu9 in #1668 - Avoid leaking secrets in log files and on the console.
- fix:issue-1667;added if condition check to not echo DB_URL by @shashank40 in #1681
- Automatically display a Modal when the backend is unable to connect.
- Add contains, reverse operations for Var by @martinxu9 in #1679
- Add special var for upload: clear_selected_files by @martinxu9 in #1703
- Support automatic serialization of date, datetime, time, and timedelta Vars in a State class.
- added changes for datetime by @wassafshahzad in #1745
- Raise TypeError when attempting to incorrectly use a state Var in a
booloritercontext. - Allow dynamic routes to work with static hosting (github pages, netlify, s3, etc)
Bug Fixes
- ReflexList: reassign field on
insertby @masenf in #1652 - Allow event handlers in parent state to be directly called from child state.
- Allow
rx.formto work with debounce inputs - Track var dependencies in comprehensions and nested functions by @masenf in #1728
- Proper serialization for chained Event payloads by @masenf in #1725
Minor Changes and Fixups
- Upgrade to v0.2.6 by @picklelo in #1669
- Revert "Use DebounceInput wrapper for fully controlled Editable" by @martinxu9 in #1670
- Use stream_logs for frontend process by @picklelo in #1682
- Fix run frontend only by @picklelo in #1706
- Update zh_cn README.md by @sszzz830 in #1685
- fix: correct the zh_cn README by @milochen0418 in #1716
- Fix setting substate client storage by @picklelo in #1723
- Avoid compile step when running production backend by @masenf in #1665
- AppHarness: disable telemetry for test apps by @masenf in #1733
- state: _init_mutable_fields for backend vars as well by @masenf in #1729
- Fix project hash and modernize type annotations by @picklelo in #1704
- Refactor: Move format_prop Static Method for Improved Reusability by @ElijahAhianyo in #1714
- ConnectionModal uses Cond for rendering by @masenf in #1739
- remove some packages requirements in frontend_packages option by @Lendemor in #1700
- App: only render default overlay_component when DefaultState is not used by @masenf in #1744
New Contributors
- @shashank40 made their first contribution in #1681
- @sszzz830 made their first contribution in #1685
- @nevdelap made their first contribution in #1724
Full Changelog: v0.2.6...v0.2.7
v0.2.6
A quick follow-up release to fix issues discovered and reported by our thriving community on Discord. πͺ
Fix Regressions
Ensure non-sqlite databases can be used #1661
Block problematic upstream package python-engineio-4.6.0 #1658
Other Changes
- Added the
stepprop toSlider[Issue #1639] by @muddi900 in #1643 - added support for limits in pagination by @wassafshahzad in #1646
- add type conversion for int,float in built-in setters by @Lendemor in #1660
New Contributors
Full Changelog: v0.2.5...v0.2.6
v0.2.5
πͺ Thanks to our amazing users and contributors!! π π
Known Regressions
- non-sqlite database access is not working #1661
Breaking Changes
Chained event handlers from return / yield must always be referenced from the State class, NOT the instance
class State(rx.State):
def handlerA(self):
...
def handlerB(self):
return self.handlerA() # β Will raise TypeError now!
def handlerC(self):
return State.handlerA() # β
Always reference chained handlers by classThe exception will look like TypeError: Your handler State.handlerB must only return/yield: None, Events or other EventHandlers referenced by their class (not using self) and will occur when the handler is called, not at compile time.
Removal of Config knobs
admin_dash- configure the admin dashboard viarx.Appinsteadbackend_transports- all connections will use websocketcors_credentialsdb_config- usedb_urlinsteadenv- specify the run environment via CLI flags toreflex run --env dev|prodenv_path- reading environment variables from a file is no longer supported (suggest use ofdocker-composeor simplysourcethe env file before runningreflex)override_os_envs- os environment variables will always take precedencepolling_max_http_buffer_size- all connections will use websocket
New Features
Support f-string formatting of State vars
Frontend rendering functions can now make use of f"built in {State.value}" style formatting, instead of + concatenation.
Node.js is automatically installed on Windows (non-WSL)
Using the cross-platform fnm tool to facilitate automatic installation of node runtime on native windows platform, where previously a manual install was needed.
POSIX support for fnm to replace nvm is coming soon.
Display system and environment information with --loglevel debug
For easier bug reporting and investigations, all relevant platform info, config, and tools used by Reflex will be logged in debug mode.
rx.selected_files Var exposes files selected by the rx.upload component
This new Var can be rendered as a frontend component:
rx.foreach(
rx.selected_files,
rx.text,
)Improvements
Frontend performance boost
Refactoring the main frontend event loop reduces event handling and rendering time by 3x.
Refactored Config class
Simplify configuration knobs and recognize all configuration values set as environment variables.
rx.form now works with more form components
Including rx.pin_input, rx.number_input, and rx.range_slider
More flexible container serialization inside State classes
setis now supported as aVartype- Recursive serialization now allows for
list,tuple, andsetof PIL image, plotly plots, and pandas dataframes.
Use βtrailingSlashβ mode to better support static site hosting
When exporting a site via reflex export, an index.html file will be created inside a directory for each static route, which makes hosting via s3, github pages, netlify, and others simpler by not requiring a βtry_filesβ rule or rewrites.
docker-example is simplified and extended
The main Dockerfile is simpler and there is now a compose.yaml and Caddy.Dockerfile which can be used to deploy a reflex app with automatic TLS support.
Other Improvements
- Expose
debounce_timeoutprop onrx.inputandrx.text_areafor tuning fully-controlled input behavior on large sites. - Ignore
*.dband files in default.gitignoretemplate NoSSRComponentsupports components using either named or default exports.
Bug Fixes
- Flex
wrapanddirectionprops accept list of values, for use at different responsive breakpoints. - Can specify
on_loadwhen defining a custom 404 page. - Raise useful exception when a user-defined State var shadows an internal name.
BUN_PATHis respected again (regression from 0.2.3)- Var operations like
to_string,and, andorreturn a new Var with the correcttype_set. - Passing a
dictas a prop where the values contain double quotes is no longer an error. (Fixrx.htmlcomponent where content contains double quotes)
Other Changes
- For show file on PyPI correctly, to use the full-path hyperlink to indicate the raw file by @milochen0418 in #1559
- PR zh/zh_tw readme update by @milochen0418 in #1557
- Add windows warning message. by @Alek99 in #1570
- Change fixture scope to be run per session rather than per function by @mat-mil in #1569
- App harness use new_process by @picklelo in #1573
- Update urls to reflex.dev by @picklelo in #1572
- Update CONTRIBUTING.md by @Alek99 in #1580
- Add AppHarness for form submit by @Lendemor in #1571
- FIXED #1598: pyproject.toml: Wrong repository URL by @jenisys in #1602
- test_dynamic_routes: fix flakyness in test_dynamic_routes by @masenf in #1603
- Fix rx.link href prop and Var.to_string type by @picklelo in #1600
- integration tests: don't shadow real error when screenshot fails by @masenf in #1608
- link: fix link with no href by @masenf in #1612
- Update .gitignore to ignore coverage.* files by @martinxu9 in #1623
- Remove unused
full_controlrelated code by @martinxu9 in #1624 - test_form_submit: poll for backend_state to be updated by @masenf in #1625
New Contributors
- @Smit-Parmar made their first contribution in #1535
- @mat-mil made their first contribution in #1568
- @jenisys made their first contribution in #1602
- @martinxu9 made their first contribution in #1614
- @danik292 made their first contribution in #1645
Full Changelog: v0.2.4...v0.2.5
v0.2.4
What's Changed
- Update Readme by @Alek99 in #1463
- Guide to clone the correct repo in CONTRIBUTING.md by @milochen0418 in #1471
- replace favicon.ico to represent reflex by @milochen0418 in #1469
- Disable fully controlled Input and TextArea by @masenf in #1383
- Fix Nextjs Dynamic Import by @Alek99 in #1480
- Use concurrent.futures for threading by @picklelo in #1483
- Bump version to 0.2.3 by @picklelo in #1481
- Full OS matrix builds for unit and integration tests (Linux, Mac, Windows) by @jackie-pc in #1460
- Windows CI: debug logs encoding fix by @jackie-pc in #1491
- Simplify rxconfig template by @picklelo in #1492
- Update README.md by @Alek99 in #1498
- fail faster in integration test by @jackie-pc in #1493
- Fix deploy command by @picklelo in #1496
- check_initialized: skip REFLEX_DIR check for backend only by @masenf in #1478
- scripts/integration: fix mismerge -- wait for $check_ports by @masenf in #1504
- docker-example: update executable and README by @masenf in #1499
- fix state reset() by @Lendemor in #1501
- CI: Basic integration test for WSL by @jackie-pc in #1510
- add main entry point to allow
python -m reflexby @masenf in #1516 - Remove Home folder for windows by @ElijahAhianyo in #1502
- fix lost events when yielding by @Lendemor in #1521
- Add alt tag for images by @picklelo in #1524
- NoSSRComponent recognizes is_default by @masenf in #1533
- Wrap Input and TextArea with DebounceInput for full control by @masenf in #1484
- Run AppHarness selenium integration tests in CI by @masenf in #1538
- Expose NoSSRComponent for downstream use by @masenf in #1537
- Get rid of mod_import by @Alek99 in #1547
Full Changelog: v0.2.3...v0.2.4