DEV Community

Discussion on: Say Goodbye To Provider Hell With react-component-pack

Collapse
 
1987cr profile image
Carlos Riera

I wouldn't install a new dependency on my project to do this when you can achieve (probably) the same result just writing a small function like this one:

const nest = (...components) => props =>
  components.reduce((children, Current) => <Current {...props}>{children}</Current>, props.children);

const ProviderPack = nest(
  AuthProvider,
  DataProvider,
  AnotherDataProvider,
  WtfProvider,
  ThisIsGettingReallyBigProvider,
  OhMyGodTheresMoreProvider
);
Enter fullscreen mode Exit fullscreen mode