
-- Children API 로 트리를 뒤질 수 있다 — 가능하지만 비추천
traverse :: Type -> ReactNode -> [Element]
traverse t = concatMap go . toArray
where
go c | not (isValidElement c) = [] -- string·number 도 들어온다
| type' c == Fragment = traverse t (children c) -- Fragment 는 푼다
| otherwise = [c | type' c == t] ++ traverse t (children c)
-- 동적 래핑: 링크가 하나라도 있으면 그대로, 아니면 <ul> 로
wrap cs | any (isJust . url) (filter isValidElement (toArray cs)) = cs
| otherwise = ul cs
-- 암묵적 의존 · 타입 약함 · 매 렌더 순회 · 예측 불가 → Compound Component 로
tabs = Tabs.Root [ Tabs.List [Tabs.Trigger "a" "A"], Tabs.Content "a" "Content" ]
-- 2013년엔 Context 도 없었다: "선언형"인데 명령형 순회를 주던 이중성
-- deepMap·deepFind·deepFilter 가 필요하면 react-children-utilities