An open API service indexing awesome lists of open source software.

https://github.com/disjukr/connect-react-context

like react-redux, connect react context to props. support typescript.
https://github.com/disjukr/connect-react-context

Last synced: about 1 month ago
JSON representation

like react-redux, connect react context to props. support typescript.

Awesome Lists containing this project

README

        

# connect-react-context
like react-redux, connect react context to props. support typescript.

## usage
```tsx
import * as React from 'react';
import { connectContext } from 'connect-react-context';
import { joinContext, ContextValues } from 'join-react-context';

const helloContext = React.createContext('hello');
const worldContext = React.createContext('world');
type Contexts = [ typeof helloContext, typeof worldContext ];
const { Provider, Consumer } = joinContext([ helloContext, worldContext ]);

const App = () => (



);

interface ComponentProps {
a: string;
b: string;
c: string;
}
const Component: React.SFC = ({ a, b, c }) => (

{ a }, { b }{ c }

);
const ConnectedComponent = connectContext, ComponentProps, 'a' | 'b'>(
Consumer,
([ hello, world ], props) => ({ a: hello, b: world, ...props }),
)(Component);
```