npm.io
1.0.0 • Published 6 years ago

another-multi-provider

Licence
MIT
Version
1.0.0
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
1

Another React Multi Provider

Clean up your deeply nested provider components!

Example

Transform your code from something that looks like this:

<AuthenticationProvider configuration={configuration}>
  <MuiPickersUtilsProvider utils={DateFnsUtils}>
    <ThemeProvider theme={theme}>
      <DialogProvider>
        <AnotherContextProvider>
          <Router>
            <App />
          </Router>
        </AnotherContextProvider>
      </DialogProvider>
    </ThemeProvider>
  </MuiPickersUtilsProvider>
</AuthenticationProvider>

to this:

<MultiProvider providers={[
  [AuthenticationProvider, { configuration }],
  [MuiPickersUtilsProvider, { utils: DateFnsUtils }],
  [ThemeProvider, { theme }],
  DialogProvider,
  AnotherContextProvider,
  Router,
]}>
  <App />
</MultiProvider>

Installation

npm install --save another-multi-provider

Usage

import MultiProvider from 'another-multi-provider';

<MultiProvider providers={[
  // providers...
]}>
  <App />
</MultiProvider>

Inspired by

License

MIT