Skip to content

Instantly share code, notes, and snippets.

@develohpanda
Created May 24, 2023 00:11
Show Gist options
  • Save develohpanda/bf6da5a2872fe9c5caa829542417ab9e to your computer and use it in GitHub Desktop.
Save develohpanda/bf6da5a2872fe9c5caa829542417ab9e to your computer and use it in GitHub Desktop.
import { ComponentType, FC, PropsWithChildren } from 'react';
const Starter: FC<PropsWithChildren> = ({ children }) => <>{children}</>;
export const withWrappers = (...params: ComponentType<PropsWithChildren>[]) =>
params.reduce((Previous, Current) => {
const Wrapped: FC<PropsWithChildren> = ({ children }) => (
<Previous>
<Current>{children}</Current>
</Previous>
);
return Wrapped;
}, Starter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment