reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
19.84k stars 1.14k forks source link

Controlled inputs throw JS warning in console #817

Closed picklelo closed 11 months ago

picklelo commented 1 year ago

The new controlled inputs/text areas works great, but throws a warning in the JS console that we should resolve.

masenf commented 1 year ago

What is the warning text?

Warning: State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().

Edit: I'm am able to consistently reproduce the warning with a full control text input in either Firefox 111.0.1 or Safari 16.3 on macOS 13.2.1.

pynecone-0.1.24

Example project:

import pynecone as pc

class State(pc.State):
    var: str = "init"

app = pc.App(state=State)

@app.add_page
def index() -> pc.Component:
    return pc.vstack(
        pc.input(value=State.var, on_change=State.set_var),
        pc.text_area(value=State.var, on_change=State.set_var),
    )

app.compile()

I was having PATH issues earlier and accidentally running the previous version without the full_control feature.

masenf commented 11 months ago

The entire full controlled input handling code has been removed.