1.0.8 • Published 11 months ago

@evanion/compose v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Known Vulnerabilities npm (scoped)

compose

A React component that allows you to cleanup your providers.

Raise your hand if your App.tsx looks like this

const App: React.FC = () => {
  return (
    <ErrorBoundary>
      <CacheProvider value={emotionCache}>
        <ThemeProvider theme={theme}>
          <TranslationProvider locale={locale} messages={messages}>
            <StateProvider state={stateStore}>
              <CoffeeProvider>
                <SanityProvider>
                  <Routes />
                </SanityProvider>
              </CoffeeProvider>
            </StateProvider>
          </TranslationProvider>
        </ThemeProvider>
      </CacheProvider>
    </ErrorBoundary>
  );
};

This package let's you go to this:

import { Provider, ComposeProvider } from "@evanion/compose";
const providers: Provider[] = [
  ErrorBoundary,
  [CacheProvider, { value: emotionCache }],
  [ThemeProvider, { theme }],
  [TranslationProvider, { locale, messages }],
  [StateProvider, { state: stateStore }],
  CoffeeProvider,
  SanityProvider,
];

const App: React.FC = () => {
  return (
    <ComposeProvider providers={providers}>
      <Routes />
    </ComposeProvider>
  );
};

In previous versions of the documentation, the documentation said that the prop should be called providers but the code expected components. This has been fixed in version 1.0.4. And ComposeProvider now accepts either providers or components as a prop. Sorry for the inconvenience.

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago