Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

582 B
Raw Blame
import type { ComponentType, ReactNode } from 'react';

export type ProviderComponent = ComponentType<{ children: ReactNode }>;

/**
 * Outermost provider first. Call only at module scope: each call creates a component identity and render-time
 * composition remounts children.
 */
export const composeProviders = (providers: ReadonlyArray<ProviderComponent>): ProviderComponent => {
  const Composed = ({ children }: { children: ReactNode }): ReactNode =>
    providers.reduceRight<ReactNode>((wrapped, Provider) => <Provider>{wrapped}</Provider>, children);
  return Composed;
};