solidjs / solidjs/solid-docs

Signal update not causing re-render

Offen
#1,009 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

good first issue help wanted
Vorherrschende Sprache
MDX
Sterne
292
Forks
361
Ø Merge
7 Std. 51 Min.
Gemergte PRs (30 T.)
1

Beschreibung

Describe the bug

This may be a me problem, but I am confused and imagine this is well above my understanding. I'm having trouble with a simple re-render when an onMount function changes a signal from false to true--in this case, used to signify that loading has finished. I have tinkered with a few things trying to get this app to work. It's a template using Colyseus + Phaser for a multiplayer server. I've added Solid JS to the front-end as per a previous, functioning app, and that's where all the trouble began!

This template is using parcel to bundle, and I've tried to maintain that, but it has been tricky integrating Solid. I've had to create
.babelrc file,
parcel.config.js file,
and update the tsconfig to
"jsx": "preserve",
"jsxImportSource": "solid-js/h" (in order to get it to stop screaming at me about a jsx-dev-runtime error)

In doing so, I've finally been able to get it to accept using Solid js, but now it's simply not rendering a signal change in the return's body.

Your Example Website or App

https://achreo.vercel.app

Steps to Reproduce the Bug or Issue
export default function App() {
    const [menu, setMenu] = createSignal<boolean>(false);
    onMount(() => {
        console.log(menu(), 'Current Menu');
        setMenu(true);
        console.log(menu(), 'Current Menu');
    });
    return (
        <div id="app">
            <Show when={menu()} fallback={<Puff color="gold"/>}>
                <div class='superCenter'>
                    <div>The Ascean</div>
                    <button>Enter Game</button>
                </div>
            </Show>
        </div>
    );
};

This is the smallest version of getting at what I'm talking about, it's simply not updating its render of the signal and reflecting that in the return.

the app above shows how it functions when it does work (this is a front-end only, single player version of the same concept I'm redesigning to incorporate a server for multiplayer)

Expected behavior

I expected it to update the rendering, but instead it remains stuck with it seeing the fallback of the Show component, a Puff from solid-spinner

Screenshots or Videos

https://github.com/user-attachments/assets/23b0900f-fdfc-4631-b6fb-70ab219a7558

Platform
  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]
Additional context

Apologies if this is a known issue, I've been trying to get this to work for a couple days now and after running into multiple, fixable errors, this seems like one that's just above my head.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der App-Funktion und ihrer Verwendung von createSignal, onMount und Show und untersuche anschließend die genannten Einstellungen in .babelrc, parcel.config.js und tsconfig. Reproduziere das minimale Beispiel und vergleiche die Solid-Integration mit der verlinkten funktionierenden App; abgeschlossen ist die Untersuchung, wenn du identifiziert hast, warum die Signaländerung den gerenderten Zweig nicht aktualisiert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
build-system, frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.