Skip to content

React Multi Provider - Clean up your deeply nested provider components!

License

Notifications You must be signed in to change notification settings

pzs/another-multi-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

React Multi Provider - Clean up your deeply nested provider components!

Resources

License

Stars

Watchers

Forks

Packages

No packages published