diff --git a/packages/di/di.tsx b/packages/di/di.tsx index 255b3265..b8fea735 100644 --- a/packages/di/di.tsx +++ b/packages/di/di.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import { createContext } from 'react'; +import React, { StatelessComponent, ComponentType, createContext } from 'react'; +export type GetNonDefaultProps = T extends {} ? never : T; export type RegistryContext = Record; const registryContext = createContext({}); @@ -8,9 +8,9 @@ const RegistryProvider = registryContext.Provider; export const RegistryConsumer = registryContext.Consumer; -export function withRegistry

(...registries: Registry[]) { - return function WithRegistry(Component: React.ComponentType

) { - const RegistryResolver: React.SFC

= (props: P) => { +export function withRegistry(...registries: Registry[]) { + return function WithRegistry

(Component: ComponentType

) { + const RegistryResolver: StatelessComponent> = (props: P) => { return ( {contextRegistries => { @@ -62,7 +62,7 @@ export class Registry { * @param id component id * @param component valid react component */ - set(id: string, component: React.ComponentType) { + set(id: string, component: ComponentType) { this.components.set(id, component); return this; @@ -73,7 +73,7 @@ export class Registry { * * @param id component id */ - get(id: string): React.ComponentType { + get(id: string): ComponentType { if (__DEV__) { if (!this.components.has(id)) { throw new Error(`Component with id '${id}' not found.`);