Auto-memoization splits local client-state button text from its setter
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python, react
- Ambito
- frontend, full-stack
Direzione di ricerca
The issue is in the auto-memoization logic for local client state. Start by examining how rx._x.client_state generates React hooks and how child components are memoized. Look at the generated JavaScript to see the separate useState calls. The fix likely involves keeping the state reader and setter in the same React component scope. Test by running the provided reproduction script and checking the DOM updates.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Automatic memoization separates a local client state's reader and setter into different React state instances. A button that renders its own client-state value does not visibly update when clicked.
Reproduced on main commit 31d57490470228c08595e73bcae1f86703880e26 and on 565dd92bfbb26c86d064e7bebfaf47321414c7a0.
import reflex as rx
count = rx._x.client_state("local_count", default=0, global_ref=False)
def index():
return rx.el.button(
count.value,
on_click=count.set_value(count.value + 1),
id="counter",
)
app = rx.App()
app.add_page(index)
Run the app, wait for hydration, and click the button. It keeps displaying 0; no browser error is reported. The expected text is 1, then 2 on the next click.
The generated Button memo has useState(0) and calls its own setter. Its text is rendered by a separate Bare memo with another useState(0). The setter therefore never updates the state that the text reads.
For comparison, rendering the value as an element prop keeps it in the same memo as the event handler and works:
rx.el.input(
type="button",
value=count.value,
on_click=count.set_value(count.value + 1),
)
Validated both cases through real clicks and DOM assertions in Chrome. Please keep a local client-state read and its setter in the same hook scope when memoizing children.
- Lingua principale
- Python
- Stelle
- 29k
- Fork
- 1.8k
- Merge medio
- 2g 22h
- PR unite (30g)
- 143
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di reflex-dev/reflex
-
Operations on a list[T] | None var throw when the value is NoneForse già presa @masenf l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reflex-dev/reflex#7826 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
reflex-dev/reflex#7825 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
PropsBase nested serialization applies parent include/exclude filters to child fieldsForse già presa @harsh21234i l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
reflex-dev/reflex#7787 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
OTel: add trace_flags to JSON log records so unsampled trace ids are recognizableForse già presa @ShaanGS l’ha presa 7 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
reflex-dev/reflex#7729 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wordingForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
reflex-dev/reflex#7260 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di reflex-dev/reflex
Issue simili
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)Forse già presa @rohit-jsfreaky l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Graphify-Labs/graphify#5160 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Variable declared without a value suppresses ${VAR:-default} expansionForse già presa @Omarinho12345 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
theskumar/python-dotenv#750 ·
I maintainer di solito rispondono entro 12 giorni
-
Minor bug: Main page buttonApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
UKGovernmentBEIS/control-arena#947 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jasonacox/Powerwall-Dashboard#897 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno