From 920e7d2b03e72043f55dbb4bddc020f407748518 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 22:35:45 +0000 Subject: docs: list of how widgets are passed --- docs/guide/typescript/first-widgets.md | 83 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 25 deletions(-) (limited to 'docs/guide') diff --git a/docs/guide/typescript/first-widgets.md b/docs/guide/typescript/first-widgets.md index a467382..ac4f739 100644 --- a/docs/guide/typescript/first-widgets.md +++ b/docs/guide/typescript/first-widgets.md @@ -354,42 +354,75 @@ inner state of widgets that does not need to be recreated. In this case you can create a [custom reactive structure](./binding#example-custom-subscribable) ::: -When there is at least one `Binding` passed as a child, the `children` -parameter will always be a flattened `Binding>`. -When there is a single `Binding` passed as a child, the `child` parameter will -be a `Binding` or a flattened `Binding>`. +# How children are passed + +Here is full list of how children and bound children can be passed to custom widgets. ```tsx -import { type Binding } from "astal" +import Binding from "astal/binding" -function MyContainer({ children }: { - children?: Binding> -}) { - // children is a Binding over an Array of widgets -} +function Parent(props: { + child?: JSX.Element | Binding | Binding> + children?: Array | Binding> +}) -return - - {num(n => range(n).map(i => ( -