mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
13 lines
322 B
TypeScript
13 lines
322 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>
|
|
);
|