Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

aniftyco-archive/react-provider-tree

Repository files navigation

React Provider Tree

Break out of provider tree hell.

Install

$ yarn add react-provider-tree

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import { createProviderTreeFromList } from 'react-provider-tree';
import { App } from './App';
import { ProviderA } from './providers/ProviderA';
import { ProviderB } from './providers/ProviderB';
import { ProviderC } from './providers/ProviderC';

const ProviderTree = createProviderTreeFromList(
  [ProviderA, { value: 'foo' }],
  [ProviderB, { value: 'bar' }],
  [ProviderC, { value: 'baz' }]
);

ReactDOM.render(
  <ProviderTree>
    <App />
  </ProviderTree>,
  document.getElementById('root')
);