/// import { derive, recipe, UI } from "commontools"; interface SubItem { id: number; name: string; active: boolean; } interface Item { id: number; title: string; subItems: SubItem[]; } interface State { items: Item[]; } export default recipe("DeriveInsideMapWithMethodChain", (state) => { return { [UI]: (
{/* Edge case: explicit derive inside mapWithPattern with method chain. The inner .filter().map() should NOT be transformed because: - subs is a derive callback parameter (unwrapped at runtime) - .filter() returns a plain JS array - Plain arrays don't have .mapWithPattern() */} {state.items.map((item) => (

{item.title}

Active items:{" "} {derive(item.subItems, (subs) => subs .filter((s) => s.active) .map((s) => s.name) .join(", ") )}

))}
), }; });