v3/packages/misc-utils/withContext/withContext.tsx

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>
);