We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check the next code:
import { render } from "solid-js/web"; import { onMount } from "solid-js"; function Button(props: any) { return ( <button class={props.children ? "withChildren" : undefined}> {props.children} </button> ); } function Test() { onMount(() => { console.log("???"); }); return <span>Test</span>; } render( () => ( <Button> <Test /> </Button> ), document.getElementById("app")!, );
Expected result: console.log("???") runs once Actual result: console.log("???") runs twice
https://playground.solidjs.com/
Expected result: console.log("???") runs once
No response
The text was updated successfully, but these errors were encountered:
Fixed by children function from solid-js
children
solid-js
import { render } from "solid-js/web"; import { onMount, children } from "solid-js"; function Button(props: any) { const memo_children = children(() => props.children); return ( <button class={memo_children() ? "withChildren" : undefined}> {memo_children()} </button> ); } function Test() { onMount(() => { console.log("???"); }); return <span>Test</span>; } render( () => ( <Button> <Test /> </Button> ), document.getElementById("app")!, );
Sorry, something went wrong.
Yeah this is by design. Children are executed lazily and created on access. So if you need to access children multiple times use the helper.
No branches or pull requests
Describe the bug
Check the next code:
Expected result: console.log("???") runs once
Actual result: console.log("???") runs twice
Your Example Website or App
https://playground.solidjs.com/
Steps to Reproduce the Bug or Issue
Expected behavior
Expected result: console.log("???") runs once
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: