# @folo/withcontext

> micro HOC compose component accepts custom context values as props

<hr />

<!-- prettier-ignore-start -->
[![NPM Version](https://img.shields.io/npm/v/@folo/withcontext.svg)](https://www.npmjs.com/package/@folo/withcontext)
[![NPM Download](https://img.shields.io/npm/dt/@folo/withcontext.svg)](https://www.npmjs.com/package/@folo/withcontext)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/react.svg)](https://www.npmjs.com/package/@folo/withcontext)
[![npm bundle size (gzip)](https://img.shields.io/bundlephobia/minzip/react.svg)](https://www.npmjs.com/package/@folo/withcontext)
[![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/jalal246/folo/blob/master/LICENSE)
[![CircleCI](https://circleci.com/gh/jalal246/folo/tree/master.svg?style=svg)](https://circleci.com/gh/jalal246/folo/tree/master)
[![Codecov](https://img.shields.io/codecov/c/github/jalal246/folo.svg)](https://codecov.io/gh/jalal246/folo)
<!-- prettier-ignore-end -->

## Installation

```
npm install @folo/withcontext
```

## Usage

```js
import withcontext from "@folo/withcontext";

const ComponentWithContext = withcontext({
  Component: MyComponent,
  Consumer,
  contextProps: ["prop1", "prop4"] // with no contextProps provided, it accepts all context props
});
```

You can compose all context props by not passing `contextProps`

```js
const ComponentWithAllContextProps = withcontext({
  Component: MyComponent,
  Consumer
});
```

## License

This project is licensed under the [MIT License](https://github.com/jalal246/folo/blob/master/LICENSE)
