Skip to content

v0.3.3 [yanked]

Compare
Choose a tag to compare
@ElijahAhianyo ElijahAhianyo released this 15 Nov 19:29
· 1212 commits to main since this release
9d13e2d

New Features

Python 3.12 is now supported

by @masenf in #2006

Next.js upgrade from 13 to 14

by @Lendemor in #2142

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

(by @masenf in #2012)

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’s range ) with rx.foreach to dynamically create form elements with dynamic names. rx.Var.range(v1, v2, step) takes in start, end and step values which should be integers or Var integers.

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

(by @masenf in #2012)

Improvements

  • Assume secure protocol (wss://) and no port If the frontend is being accessed via HTTPS and the API_URL is either localhost, 0.0.0.0 or :: 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

Bug Fixes

  • fix an issue where some fields in State.router.headers were 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

Full Changelog: v0.3.2...0.3.3