import * as React from 'react' ; import { ProxyProps } from './helpers/proxy_types' ; type Options = { childContextTypes : { [ index ] : any ; } ; } ; export function createContextProxy ( { childContextTypes } ) { class ContextProxy extends React . Component < ProxyProps > { static childContextTypes = childContextTypes ; getChildContext ( ) { return this . props . proxyConfig && this . props . proxyConfig . context ? this . props . proxyConfig . context : { } ; } render ( ) { const { nextProxy , ... rest } = this . props ; const { value : NextProxy , next } = nextProxy ; return < NextProxy { ... rest } nextProxy = { next ( ) } / > ; } } return { proxy : ContextProxy as any , key : 'context' } ; }