https://github.com/uittorio/react-connect-ctx
A utility to connect functional component with the context
https://github.com/uittorio/react-connect-ctx
connect react reactcontext reactjs
Last synced: 9 months ago
JSON representation
A utility to connect functional component with the context
- Host: GitHub
- URL: https://github.com/uittorio/react-connect-ctx
- Owner: uittorio
- License: mit
- Created: 2019-10-13T16:13:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:38:22.000Z (almost 3 years ago)
- Last Synced: 2025-03-12T18:04:33.794Z (10 months ago)
- Topics: connect, react, reactcontext, reactjs
- Language: TypeScript
- Size: 468 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-connect-ctx
[](https://badge.fury.io/js/react-connect-ctx)
[](https://www.npmjs.com/package/react-connect-ctx)
Connect React Context to your component easily and with type safety
## Why
- You dont want your Component to know about React.Context
- You want to unit test your component without providing a context
## Installation
```
npm i react-connect-ctx
```
## Usage
```ts
import { connectContext } from 'react-connect-ctx';
export default connectContext(APP_CONTEXT)(
PersonComponent,
(context: AppContext): Partial => {
return {
api: context.api
}
});
```
##[Click for full Example](docs/EXAMPLE.md)