2016-09-21 13 views

回答

1

您要找的類型叫做ReactClass。任何組件的類型將是ReactClass<any>

看看這個類似的問題:What type to use for things React can render?

+0

'ReactClass <*>'只是一個小更安全(如果這與使用情況符合) – inlinestyle

+0

'ReactClass <*>'如果將其用作許多不同組件的類型,可能會造成一些麻煩。例如,作爲從一個條件分支返回'Foo'和從另一個分支返回'Bar'的返回類型。 Flow將無法弄清''Foo |應該是什麼' Bar' –

1
type FunctionComponent<P> = (props: P) => ?React$Element<any>; 
type ClassComponent<D, P, S> = Class<React$Component<D, P, S>>; 
type Component<D, P, S> = ClassComponent<D, P, S> | FunctionComponent<P>; 

type Props = { 
    Component: Component<void, {}, void> 
}; 
0
type Props = { 
Component: React.Component<*> 
}; 

參考從反應類型定義:

class React.Component<P = {}, S = {}> 
interface React.Component<P = {}, S = {}>