`ref={…}` reading an equation compiles to an untracked memo read in element setup (STRICT_READ_UNTRACKED on Solid's dev build)
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
- 52/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- frontend
Línea de trabajo
Start with compiler/src/emit.rs:1666, where ref attributes are lowered, and trace the emitted setup code in the reproduction. The report also points to compiler/src/emit.rs:1215-1233 and :1356 for declared-shape member projections. Check existing compiler tests for ref lowering and declared object projections; done means a plain ref expression no longer triggers Solid's STRICT_READ_UNTRACKED warning, with the reported object projection behavior addressed or its scope clarified.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
An element ref={…} whose value comes from an equation compiles to an untracked read of that equation's memo in the element's setup code. Solid's dev build then warns STRICT_READ_UNTRACKED on every mount.
Versions: @reactivescript/compiler, @reactivescript/runtime 0.3.1; solid-js / @solidjs/web 2.0.0-rc.21; @solidjs/vite-plugin 3.0.0-next.57.
Repro
attach.js:
export const attach = (el) => { el.textContent = "x" }
main.rx:
import pure { attach } from "./attach"
export default component App() {
source n := 0
o = { f: attach, n: n }
{if n >= 0 {
<div ref={o.f} />
}}
<p>{o.n}</p>
}
Compiled (app("main.rx", "dom")), inside the Show child:
var _el$2 = _$getNextElement(_tmpl$2);
var _ref$ = v$o()?.f;
(typeof _ref$ === "function" || Array.isArray(_ref$)) && _$ref(() => _ref$, _el$2);
Mounted with createApp(...).mount(main(app)) on Solid's dev build:
[STRICT_READ_UNTRACKED] Reactive value read directly in <Show> will not update. ...
in <V$App> › <Show> › value
Without the if, the same read happens in the component body and warns with read directly in <V$App>.
The same happens with a primitive declared in a .d.rx (MO-10) when its object result is bound whole and the ref is projected in markup:
// widget.d.rx
export pure fn createWidget(options: { key: string }): { ref: (el: HTMLElement) => void; token: ref string | null; reset: () => void }
w = createWidget({ key: "k" })
...
<div ref={w.ref} />
This lowers to const v$w = __rt.memo(null, () => ({ ref: r$w["ref"], token: r$w["token"](), reset: r$w["reset"] })) and var _ref$ = v$w()?.ref;, with the same warning. Destructuring instead ({ ref: wref, token } = createWidget(...)) binds v$wref = () => r$w["ref"], which is not a node, and does not warn. ref={peek o.f} also does not warn (__rt.untrack(() => v$o()?.f)).
Expected
No warning for a plain ref={…}. Solid applies a ref once, when the element is created, so the read cannot be tracked whatever it reads. The compiler should lower the ref attribute's expression as a one-time read (__rt.untrack(() => …), what peek emits), or the checker should ask for peek there. As it is, .rx code that looks correct triggers a Solid diagnostic the author can't trace back to their source.
A second, smaller point for the MO-10 case: a projection of a declared object part in an expression (w.ref, w.token in markup) goes through the whole-result memo. That memo rebuilds the object whenever token changes. The declaration-level projection path already reads the part directly (x = w.ref → r$w["ref"]). Doing the same for a projection in an expression (r$w["ref"] for a function part, r$w["token"]() for a ref part) would avoid both the memo read and the object churn.
Cause
compiler/src/emit.rs:1666(attr) lowersreflike any other attribute, in reactive context. The JSX transform then emits its once-onlyvar _ref$ = <expr>in the element's setup code.compiler/src/emit.rs:1215-1233handlesMemberon an instance with a declared shape only when it is an equation's whole right-hand side. In an expression,compiler/src/emit.rs:1356lowers it generically tov$w()?.ref.
- Lenguaje dominante
- TypeScript
- Estrellas
- 127
- Forks
- 7
- Merge medio
- 15 h 42 min
- PR fusionados (30 d)
- 63
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin 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 solidjs/reactivescript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
solidjs/reactivescript#96 ·
Los mantenedores suelen responder en 1 día
-
Vite front end keeps serving a failed build after the missing/broken imported module is fixedPosiblemente ocupada @cgaaf la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
solidjs/reactivescript#84 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
solidjs/reactivescript#77 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
solidjs/reactivescript#74 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
solidjs/reactivescript#97 ·
Los mantenedores suelen responder en 1 día
Todos los issues de solidjs/reactivescript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
GetStream/stream-chat-react#3467 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
vercel-labs/ui#1139 ·
Los mantenedores suelen responder en 1 día
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Posiblemente ocupada @goranai la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
[Bug] IntegerRange.contains counts a non-integer just above max as inside an inclusive rangeAbiertobot:ai-assisted component:platform-js status:untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
midnightntwrk/platform-js#93 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100