如何流式输入组件?

时间:2016-09-21 13:13:19

标签: reactjs flowtype

type Props = {
  Component: ???
}
const AnotherComp = ({Component}: Props) => (
  <Component />
)

为组件添加道具的正确方法是什么?

4 个答案:

答案 0 :(得分:2)

pivot.join(filt).rename(columns={'code Date': 'count'})

# code group       High     Medium  count   code
# rec                                           
# 10001      2015-11-05        NaT      2    X11
# 10002      2015-10-04 2015-10-04      1  X11.1

答案 1 :(得分:1)

您正在寻找的类型称为ReactClass。任何组件的类型都是ReactClass<any>

查看类似的问题:What type to use for things React can render?

答案 2 :(得分:0)

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

来自反应类型定义的参考:

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

答案 3 :(得分:0)

我认为这就是您要寻找的:

// Component we want to pass as a prop
class MyComponent extends React.Component<{}> {}

type Props = {
  Component: React.Element<typeof MyComponent>
}

const AnotherComp = ({ Component }: Props) => (
  <Component />
)

文档链接:https://flow.org/en/docs/react/types/#toc-react-element