Advanced / Interop & Async

flatten

Resolves a children value to its renderable form: unwraps zero-arg functions (accessors), recursively flattens arrays, and optionally skips non-rendering values (null, undefined, true, false, "").

Used internally by flow components and by the renderer to walk a children tree. App code rarely needs this directly — see children() in solid-js for the user-facing helper that memoizes the result.


Import

import { flatten } from "solid-js";

Type signature

function flatten(
children: any,
options?: { skipNonRendered?: boolean; doNotUnwrap?: boolean }
): any;

Parameters

children

Value or array of values to flatten

options

  • skipNonRendered — drop values that won't render
    • doNotUnwrap — leave function children as-is (caller will resolve)

Examples

// Custom renderer walking a children tree manually. Most authors should
// use `children()` from solid-js, which memoizes the resolved value.
function renderChildren(value: unknown): unknown {
return flatten(value, { skipNonRendered: true });
}
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page