我试图从PropTypes
迁移到我的React组件中的Flow
类型检查。
请问PropTypes.func
中Flow
的等价物,指明一个道具是一个函数?
我的代码看起来像这样:
import * as React from 'react'
type Props = {
doSomething: /* function */
}
class MyComponent extends React.Component<Props> {}
您可以使用:
type Props = {
doSomething: () => void,
}
或者如果需要,指定参数。
有一个更清晰的方式:
type Props = {
doSomething: Function // with capital letter
}