Auto-memoization splits local client-state button text from its setter
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python, react
- Área
- frontend, full-stack
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 29k
- Forks
- 1.8k
- Merge medio
- 2 d 22 h
- PR fusionados (30 d)
- 143
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de reflex-dev/reflex
-
Operations on a list[T] | None var throw when the value is NonePosiblemente ocupada @masenf la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
reflex-dev/reflex#7826 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
reflex-dev/reflex#7825 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
PropsBase nested serialization applies parent include/exclude filters to child fieldsPosiblemente ocupada @harsh21234i la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
reflex-dev/reflex#7787 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
OTel: add trace_flags to JSON log records so unsampled trace ids are recognizablePosiblemente ocupada @ShaanGS la tomó hace 7 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
reflex-dev/reflex#7729 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wordingQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
reflex-dev/reflex#7260 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de reflex-dev/reflex
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
UKGovernmentBEIS/inspect_ai#6512 ·
Los mantenedores suelen responder en 1 día
-
area/c++ area/core kind/bug-report
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
tensorflow/quantum#1140 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Kav-K/GPTDiscord#501 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
UKGovernmentBEIS/inspect_evals#2863 · 1 comentario ·
Los mantenedores suelen responder en 1 día