pub fn Fragment<'a>(cx: &'a Scoped<'a, FragmentProps<'a>>) -> Option<VNode<'a>>
Expand description
Create inline fragments using Component syntax.
Details
Fragments capture a series of children without rendering extra nodes.
Creating fragments explicitly with the Fragment component is particularly useful when rendering lists or tables and a key is needed to identify each item.
Example
ⓘ
rsx!{
Fragment { key: "abc" }
}
Usage
Fragments are incredibly useful when necessary, but do add cost in the diffing phase. Try to avoid highly nested fragments if you can. Unlike React, there is no protection against infinitely nested fragments.
This function defines a dedicated Fragment
component that can be used to create inline fragments in the RSX macro.
You want to use this free-function when your fragment needs a key and simply returning multiple nodes from rsx! won’t cut it.