reflex icon indicating copy to clipboard operation
reflex copied to clipboard

The default_value set in the input component in debounce_input does not work.

Open Evenzel opened this issue 9 months ago β€’ 1 comments

Describe the bug The default_value set in the input component in debounce_input does not work.

To Reproduce Steps to reproduce the behavior:

rx.debounce_input(
    rx.input(
        default_value='tomato'
        on_change= Anystatefunction
    ),
),

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 3.11.4
  • Reflex Version: 0.4.9
  • OS: Windows 10
  • Browser (Optional): Chrome

Additional context Add any other context about the problem here.

Evenzel avatar Apr 30 '24 15:04 Evenzel

The debounce component we are using "react-debounce-input" does not support defaultValue so it's not really a bug, just an unsupported feature. (and the lib has no update in last 2 years so unlikely they will add this.)

There is little we can do on our side aside from replacing the component for a better one, if there is one.

On the other hand, there is no reason to use rx.debounce_input if you are not in fully-controlled mode (where default_value doesn't make sense).

Instead, for situation where you want debounce but not setting the value props, on latest main /0.5.0 you can do :

rx.input(
    on_change=TestState.set_num.debounce(1000),
    placeholder="your number",
    default_value="5",
),

Lendemor avatar May 03 '24 13:05 Lendemor