# react2angular-shared-context

> Share context between React components in react2angular.

Latest version **1.2.1** (published 2022-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install react2angular-shared-context
pnpm add react2angular-shared-context
yarn add react2angular-shared-context
bun add react2angular-shared-context
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2022-10-17 |
| First published | 2020-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | https://github.com/seahorsepip |
| Maintainers | seahorsepip |

## Links

- npm: https://www.npmjs.com/package/react2angular-shared-context
- Repository: https://github.com/seahorsepip/react2angular-shared-context
- Homepage: https://github.com/seahorsepip/react2angular-shared-context#readme
- Issues: https://github.com/seahorsepip/react2angular-shared-context/issues
- npm.io page: https://npm.io/package/react2angular-shared-context

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0

## Recent versions

- 1.2.1 (latest) — 2022-10-17
- 1.2.0 — 2022-10-12
- 1.1.2 — 2022-01-29
- 1.1.1 — 2020-12-22
- 1.1.0 — 2020-11-17
- 1.0.3 — 2020-05-06
- 1.0.2 — 2020-04-20
- 1.0.1 — 2020-04-20
- 1.0.0 — 2020-04-20

## README

# react2angular-shared-context

> Share context between React components in react2angular.

[![NPM](https://img.shields.io/npm/v/react2angular-shared-context.svg)](https://www.npmjs.com/package/react2angular-shared-context) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save react2angular-shared-context
```

## Usage

```tsx
import { react2angular } from 'react2angular';
import React, { FunctionComponent } from 'react'
import { ProviderAbc, ConsumerAbc } from './context/abc'

import createSharedContext from 'react2angular-shared-context'

// Root component with context providers
const Root: FunctionComponent<{foo: number}> = ({foo, children}) => (
  <ProviderAbc foo={foo}>
      {children}
  </ProviderAbc>
);

// Example component that consumes providers defined in Root component
const MyExample: FunctionComponent<{bar: string}> = ({bar}) => (
  <ConsumerAbc>
    {({a, b, c}) => <p>{bar} says: {a} x {b} = {c}</p>}
  </ConsumerAbc>
);

// Create shared context instance
const sharedContext = createSharedContext(Root);

// Define shared context component first
// This component can be optionally wrapped in react-hot-loader
angular
  .module('example')
  .component('sharedContextReact', react2angular(sharedContext.component, ['foo']));

// Wrap example component with shared context
// Do not wrap this component with react-hot-loader because the shared context instance will already handle this
angular
  .module('example')
  .component('myExampleReact', react2angular(sharedContext.use(MyExample), ['bar']));
```

## License

MIT © [https://github.com/seahorsepip](https://github.com/seahorsepip)

---
_Source: https://npm.io/package/react2angular-shared-context · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
