Describe the bug
In some cases, Solid will mysteriously not run effects (not even the initial first run).
Your Example Website or App
https://playground.solidjs.com/anonymous/fdbfd2dd-56ee-49cb-b77e-a615cb8af653
Steps to Reproduce the Bug or Issue
- write a template with a function as a child in text content
- read and write a signal in a specific location in the template
- observe that effect made with createEffect doesn't run, not even initially
Example code:
import { createEffect, createSignal } from "solid-js"
import html from "solid-js/html"
import { render } from "solid-js/web"
export class DrippyScene extends HTMLElement {
connectedCallback() {
console.log("connectedCallback")
// This never logs:
createEffect(() => console.log(" ####################### EFFECT!"))
}
}
customElements.define("drippy-scene", DrippyScene)
const [isDesktop, setIsDesktop] = createSignal(false)
render(
() => html`
<drippy-scene></drippy-scene>
${() => {
if (!isDesktop()) setIsDesktop(true)
return ""
}}
<div></div>
`,
document.querySelector("#app")!,
)
/*
Things you can do to make the effect run:
- comment out the line with if (!isDesktop())
*/
Expected behavior
Expect effects to always run at least once initially.
Ways to make the effect run:
- comment out the line with
if (!isDesktop)
- or delete the text content interpolation entirely
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- Version: 144
Additional context
Here are a few different ways to make it happen:
Describe the bug
In some cases, Solid will mysteriously not run effects (not even the initial first run).
Your Example Website or App
https://playground.solidjs.com/anonymous/fdbfd2dd-56ee-49cb-b77e-a615cb8af653
Steps to Reproduce the Bug or Issue
Example code:
Expected behavior
Expect effects to always run at least once initially.
Ways to make the effect run:
if (!isDesktop)Screenshots or Videos
No response
Platform
Additional context
Here are a few different ways to make it happen:
if (!isDesktop())${}interpolation in the text content altogether${() => ""}<bottom-sheet></bottom-sheet>if (!isDesktop())