-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
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:
- https://playground.solidjs.com/anonymous/86d0ecb9-cda4-423a-89b3-cface3d5bea2
- Ways to make the effect run:
- comment out the line with
if (!isDesktop()) - or delete the
${}interpolation in the text content altogether
- comment out the line with
- Ways to make the effect run:
- https://playground.solidjs.com/anonymous/8188dbc6-9fac-4698-a5a9-0a6247a394f4
- Ways to make the effect run:
- delete the
${() => ""} - or delete the
<bottom-sheet></bottom-sheet> - or comment out the line with
if (!isDesktop())
- delete the
- Ways to make the effect run:
- https://playground.solidjs.com/anonymous/71db6422-a87c-4bff-b324-57a0effed12a (JSX too)
Metadata
Metadata
Assignees
Labels
No labels