@opencreek/provider-stack
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

Provider Stack npm

Are you tired of the mountain of react providers, just lying in your app.tsx? This simple library solves that for you!

Usage

// app.tsx
import { providers, ProviderStack } from "@opencreek/provider-stack"



// Somewhere in your app component

const theme = //...

const providerStack = useMemo(() =>
    providers()
        .add(ThemeProvider, {theme: theme})
        .add(SomeOtherProvider),
    [theme] // make sure to add everything that needs to trigger an update
)


return (
    <ProviderStack providers={providerStack}>
        // Rest of your app
    </ProviderStack>
)

Some more Detail

providers()
    .add(ThemeProvider, { theme: theme }) // The second parameter are the props of the provider (excluding `children`)
    .add(SomeOtherProvider) // If no props are needed, you can just leave them out!

Readme

Keywords

none

Package Sidebar

Install

npm i @opencreek/provider-stack

Weekly Downloads

229

Version

0.3.1

License

MIT

Unpacked Size

10.2 kB

Total Files

9

Last publish

Collaborators

  • happenslol
  • reckter
  • lionc
  • mhlz