Flow:PropTypes.func在flow中相当于什么?
Flow: What is the equivalent of PropTypes.func in flow?
我正尝试在我的 React 组件中从 PropTypes
迁移到 Flow
类型检查。
请问 Flow
中的 PropTypes.func
等价于什么来指定一个 prop 是一个函数?
我的代码如下所示:
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
}
我正尝试在我的 React 组件中从 PropTypes
迁移到 Flow
类型检查。
请问 Flow
中的 PropTypes.func
等价于什么来指定一个 prop 是一个函数?
我的代码如下所示:
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
}