import type { ComponentType, PropsWithChildren } from 'react' export const composeProviders = ( ...arr: ComponentType>[] ): ComponentType => arr.length === 1 ? arr[0] : ({ children }) => arr.reduceRight( (accumulatedChildren, Provider) => ( {accumulatedChildren} ), children, )