Renders a list of items efficiently, with keyed updates based on the identity of the items themselves. This makes it efficient for lists where items are added, removed, or reordered.
Type:
Parameters:
each
: An array of items to render or a falsy valuechildren
: A function that returns the component for each item, receiving the item and a reactive indexfallback
: Optional fallback content when the array is emptyExample:
Renders a list with index-based tracking for efficient updates. Unlike <For>
, it tracks items by their position in the array rather than their identity, which can be more efficient for lists that are frequently updated but not reordered.
Type:
Parameters:
each
: An array of items to render or a falsy valuechildren
: A function that returns the component for each item, receiving a reactive getter for the item and the static indexfallback
: Optional fallback content when the array is emptyExample:
Conditionally renders content based on a boolean value. Provides efficient updates when the condition changes.
Type:
Parameters:
when
: A boolean value determining whether to show the contentchildren
: The content to show when when
is true. Can be a JSX element or a function that takes the resolved value of when
fallback
: Optional content to show when when
is falsekeyed
: Optional flag to associate the block with the value of when
, useful when when
is an object referenceExample:
Renders the first matching case component. Similar to a switch statement, but for JSX content.
Type:
Parameters:
fallback
: Optional content to show when no cases matchchildren
: A list of <Match>
componentsExample:
A component used with <Switch>
to define conditional cases.
Type:
Parameters:
when
: A boolean condition determining if this case should be renderedkeyed
: Optional flag to enable keyed modechildren
: The content to render if the condition is true. Can be a JSX element or a functionExample:
Catches errors in child components and renders a fallback UI. Prevents errors from propagating up the component tree.
Type:
Parameters:
fallback
: A function that returns the fallback UI when an error occurs. It receives the error and a reset functionchildren
: The child components to wrapExample: