UNPKG

react-element-replace

Version:

React utility methods that transforms element subtrees, replacing elements following the provided rules.

7 lines (6 loc) 362 B
import * as React from "react"; export declare type ChildrenFunc<T, S> = (newState: S) => T | T[]; export interface Visitor<T = any, S = any> { visit(element: React.ReactNode, state: S, children?: (newState: S) => T | T[]): T; } export declare function traverseElementTree<T = any, S = any>(node: React.ReactNode, visitor: Visitor<T, S>, state: S): T;