# react-with-context

> Pass context into React components and replace for React.withContext

Latest version **2.0.0** (published 2017-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-with-context
pnpm add react-with-context
yarn add react-with-context
bun add react-with-context
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-09-27 |
| First published | 2016-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | mattzeunert |
| Maintainers | mattzeunert |
| Keywords | unit-testing, react, react-context, jest, karma |

## Links

- npm: https://www.npmjs.com/package/react-with-context
- Repository: https://github.com/mattzeunert/react-with-context
- Homepage: https://github.com/mattzeunert/react-with-context#readme
- Issues: https://github.com/mattzeunert/react-with-context/issues
- npm.io page: https://npm.io/package/react-with-context

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^15.6.2
- [@types/react](https://npm.io/package/@types/react.md) ^16.0.7

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-09-27
- 1.2.1 — 2017-02-21
- 1.2.0 — 2017-02-20
- 1.0.2 — 2016-01-21
- 1.0.1 — 2016-01-21
- 1.0.0 — 2016-01-21

## README

# React WithContext

WithContext passes a specified context object to its child components. This is useful when writing unit tests for React components.

You can use it to replace `React.withContext`, which was removed in React 0.14.

## Usage

```jsx
<WithContext context={context}>
   <ExampleComponent />
</WithContext>
```

Or, including import and rendering with TestUtils:

```jsx
import WithContext from "react-with-context"

const context = { greeting: "Hello" };
TestUtils.renderIntoComponent(
	<WithContext context={context}>
    	<ExampleComponent />
	</WithContext>
);
```

[Check out the full example repo.](https://github.com/mattzeunert/react-with-context-demo)

## Installation

> npm install react-with-context --save-dev

## Contributing

Use `babel --out-file WithContext.dist.js src/WithContext.js` to compile the component. Then run `npm test`.

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