
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@bndl-io/context-providers-provider
Advanced tools
A React utility component for managing complex context dependencies. Automatically sorts and nests context providers based on dependencies, promoting clean and maintainable context usage patterns.
A React utility component for managing complex context dependencies. Automatically sorts and nests context providers based on dependencies, promoting clean and maintainable patterns for context usage.
React applications often rely on multiple context providers to manage state, theming, authentication, and more. However, managing these providers can quickly lead to deeply nested and unmanageable component trees, especially when providers depend on one another.
@bndl-io/context-providers-provider
Solves This:ProviderComponents
.Install the library via npm:
npm install @bndl-io/context-providers-provider
or with yarn:
yarn add @bndl-io/context-providers-provider
Each provider is defined as an object with the following structure:
type ProviderConfig = {
name: string;
C: (children: ReactNode) => JSX.Element; // The provider component
dependencies: string[]; // Names of other providers this provider depends on
};
For example:
const providers = [
{
name: 'Auth',
C: children => <AuthProvider>{children}</AuthProvider>,
dependencies: ['Theme'], // Auth depends on Theme
},
{
name: 'Theme',
C: children => <ThemeProvider>{children}</ThemeProvider>,
dependencies: [], // No dependencies
},
{
name: 'Config',
C: children => <ConfigProvider>{children}</ConfigProvider>,
dependencies: ['Auth'], // Config depends on Auth
},
];
Use the ContextProvidersProvider
to automatically sort and nest providers based on their dependencies:
import React from 'react';
import ContextProvidersProvider from '@bndl-io/context-providers-provider';
const providers = [
{
name: 'Auth',
C: children => <AuthProvider>{children}</AuthProvider>,
dependencies: ['Theme'],
},
{
name: 'Theme',
C: children => <ThemeProvider>{children}</ThemeProvider>,
dependencies: [],
},
{
name: 'Config',
C: children => <ConfigProvider>{children}</ConfigProvider>,
dependencies: ['Auth'],
},
];
const App = () => {
return (
<ContextProvidersProvider providers={providers}>
<YourApp />
</ContextProvidersProvider>
);
};
The above setup would result in the following provider tree:
<ThemeProvider>
<AuthProvider>
<ConfigProvider>
<YourApp />
</ConfigProvider>
</AuthProvider>
</ThemeProvider>
ContextProvidersProvider
providers
: An array of ProviderConfig
objects. Each config must include:
name
: A unique string identifying the provider.C
: A function that renders the provider component, wrapping its children.dependencies
: An array of strings identifying the providers this provider depends on.children
: The children to be rendered inside the nested providers.createContextProvidersProvider
A utility function to create a ContextProvidersProvider
component dynamically.
import { createContextProvidersProvider } from '@bndl-io/context-providers-provider';
const providers = [
{
name: 'Auth',
C: children => <AuthProvider>{children}</AuthProvider>,
dependencies: ['Theme'],
},
{
name: 'Theme',
C: children => <ThemeProvider>{children}</ThemeProvider>,
dependencies: [],
},
{
name: 'Config',
C: children => <ConfigProvider>{children}</ConfigProvider>,
dependencies: ['Auth'],
},
];
const ContextWrapper = createContextProvidersProvider({ providers });
const App = () => (
<ContextWrapper>
<YourApp />
</ContextWrapper>
);
export default App;
ContextProvidersProvider
wrapper with the given providers.ContextProvidersProvider
.MIT License
Copyright (c) DatHuis B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
We welcome contributions! Please open an issue or submit a pull request for any bugs, features, or enhancements.
FAQs
A React utility component for managing complex context dependencies. Automatically sorts and nests context providers based on dependencies, promoting clean and maintainable context usage patterns.
The npm package @bndl-io/context-providers-provider receives a total of 6 weekly downloads. As such, @bndl-io/context-providers-provider popularity was classified as not popular.
We found that @bndl-io/context-providers-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.