mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 11:59:11 +00:00
10 lines
292 B
TypeScript
10 lines
292 B
TypeScript
import * as React from 'react';
|
|
|
|
export const withContext = <T, K extends T>(
|
|
Context: React.Context<T>,
|
|
Component: React.ComponentType<K>
|
|
): React.FunctionComponent<K> => (props) => (
|
|
<Context.Consumer>
|
|
{(context) => <Component {...props} {...context} />}
|
|
</Context.Consumer>
|
|
);
|