Last active
August 23, 2024 14:40
-
-
Save thebinaryfelix/6f85a9ec7cad11accb71f22d8e2edfec to your computer and use it in GitHub Desktop.
Revisions
-
thebinaryfelix revised this gist
Oct 30, 2022 . 1 changed file with 0 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,27 +31,3 @@ export const ProviderComposer = (props: IProviderComposerProps) => { return <ComposedProviders>{props.children}</ComposedProviders> } -
thebinaryfelix revised this gist
Oct 30, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,6 +46,7 @@ How to use </ProviderComposer> Instead of nesting providers <FirstProvider> <SecondProvider> <ThirdProvider> -
thebinaryfelix revised this gist
Oct 30, 2022 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ export interface IProviderComposerProps extends React.PropsWithChildren { /** * Providers list * */ with: React.FC<React.PropsWithChildren>[] } @@ -44,4 +44,13 @@ How to use > {children} </ProviderComposer> Instead of nesting providers <FirstProvider> <SecondProvider> <ThirdProvider> {children} </ThirdProvider> </SecondProvider> </FirstProvider> */ -
thebinaryfelix revised this gist
Oct 30, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,6 +42,6 @@ How to use ThirdProvider ]} > {children} </ProviderComposer> */ -
thebinaryfelix created this gist
Oct 30, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ export interface IProviderComposerProps extends React.PropsWithChildren { /** * Lista de providers * */ with: React.FC<React.PropsWithChildren>[] } const ComposerFragment: React.FC<React.PropsWithChildren> = ({ children, }): JSX.Element => <>{children}</> const providerReducer = ( ParentProvider: React.FC<React.PropsWithChildren>, ChildProvider: React.FC<React.PropsWithChildren>, ) => ({ children }: React.PropsWithChildren) => ( <ParentProvider> <ChildProvider>{children}</ChildProvider> </ParentProvider> ) /** * @Component * @name ProviderComposer * @description Component that receives a list of providers and composes them to a single component. */ export const ProviderComposer = (props: IProviderComposerProps) => { const ComposedProviders = props.with.reduce(providerReducer, ComposerFragment) return <ComposedProviders>{props.children}</ComposedProviders> } /* How to use <ProviderComposer with={[ FirstProvider, SecondProvider, ThirdProvider ]} > {/* Here be dragons... 🐉 */} </ProviderComposer> */