import { ReactNode, FunctionComponent } from "react"; type Children = { children?: ReactNode; }; export type Provider = [FunctionComponent, unknown?]; /** * Recursively builds a React component tree based on the provided array of providers. * Each provider is an array where the first item is a React function component and the second item is an optional parameters object. * This function wraps the components around each other, in the order they appear in the input array, passing the respective params to each. * * @param {Provider[]} providers - An array of providers, where each provider is a tuple of a FunctionComponent and an optional parameters object. * @returns {unknown} - Returns a recursively composed FunctionComponent, wrapping all the provided components in order. * * @example * * import React from 'react'; * const ComponentA = ({ children }) =>
{children}
; * const ComponentB = ({ children }) =>
{children}
; * const ComponentC = ({ children }) =>
{children}
; * * const providers: Provider[] = [ * [ComponentA, { id: 'A' }], * [ComponentB, { id: 'B' }], * [ComponentC, { id: 'C' }], * ]; * * const Tree = FlattenProviders(providers); * * // Rendering would result in this structure: * // * // * // * // ... * // * // * // * */ declare const FlattenProviders: (providers: Provider[]) => unknown; export { FlattenProviders };