Say goodbye to provider hell with react-component-pack, a utility that allows you to group multiple components into a single one
npm install react-component-pack
With react-component-pack
you can go from this:
function App() {
return (
<AuthProvider>
<DataProvider>
<AnotherDataProvider>
<WtfProvider>
<ThisIsGettingReallyBigProvider>
<OhMyGodTheresMoreProvider>
<FinallySomeRealComponents />
</OhMyGodTheresMoreProvider>
</ThisIsGettingReallyBigProvider>
</WtfProvider>
</AnotherDataProvider>
</DataProvider>
</AuthProvider>
);
}
To this:
import { createPack } from 'react-component-pack';
const ProviderPack = createPack(
AuthProvider,
DataProvider,
AnotherDataProvider,
WtfProvider,
ThisIsGettingReallyBigProvider,
OhMyGodTheresMoreProvider
);
function App() {
return (
<ProviderPack>
<FinallySomeRealComponents />
</ProviderPack>
);
}