react-connect-ctx
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

react-connect-ctx

npm version Downloads

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

import { connectContext } from 'react-connect-ctx';
 
export default connectContext(APP_CONTEXT)(
    PersonComponent,
    (context: AppContext): Partial<ComponentAProps> => {
        return {
           api: context.api
        }
});
 

Click for full Example

Package Sidebar

Install

npm i react-connect-ctx

Weekly Downloads

2

Version

1.0.7

License

MIT

Unpacked Size

4.08 kB

Total Files

5

Last publish

Collaborators

  • uittorio