2.1.0 • Published 9 months ago

@saneksa/react-context-composer v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

NPM GitHub license

Installation

yarn add @saneksa/react-context-composer

The Problem

In projects on react there are a lot of contexts, it becomes very difficult to read such things

<ContextA.Provider>
  <ContextB.Provider>
    <ContextC.Provider>...</ContextC.Provider>
  </ContextB.Provider>
</ContextA.Provider>

Usage

See it in action at codesandbox

function App() {
  return composeContexts([
    [ThemeContext, theme[Theme.red]],
    [LanguageContext, Languages.cn],
  ])(
    <div>
      <Children />
      <br />
      ...child elements using contexts
    </div>
  );
}

In my proposed variant, the check of context value types works correctly

2.1.0

9 months ago

2.0.0

9 months ago

1.0.1

2 years ago

1.0.0

2 years ago