@folo/withcontext
Version:
micro HOC compose component accepts custom context values as props
47 lines (34 loc) • 1.67 kB
Markdown
# @folo/withcontext
> micro HOC compose component accepts custom context values as props
<hr />
<!-- prettier-ignore-start -->
[](https://www.npmjs.com/package/@folo/withcontext)
[](https://www.npmjs.com/package/@folo/withcontext)
[](https://www.npmjs.com/package/@folo/withcontext)
[](https://www.npmjs.com/package/@folo/withcontext)
[](https://github.com/jalal246/folo/blob/master/LICENSE)
[](https://circleci.com/gh/jalal246/folo/tree/master)
[](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)