最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Flow: What is the equivalent of PropTypes.func in flow? - Stack Overflow

programmeradmin3浏览0评论

I am trying to migrate from PropTypes to Flow type checking in my React ponents.

Please what is the equivalent of PropTypes.func in Flow, to specify that a prop is a Function ?

My code looks like this:

import * as React from 'react'

type Props = {
  doSomething: /* function */
}

class MyComponent extends React.Component<Props> {}

I am trying to migrate from PropTypes to Flow type checking in my React ponents.

Please what is the equivalent of PropTypes.func in Flow, to specify that a prop is a Function ?

My code looks like this:

import * as React from 'react'

type Props = {
  doSomething: /* function */
}

class MyComponent extends React.Component<Props> {}
Share Improve this question asked Jan 15, 2018 at 12:57 acmouneacmoune 3,4235 gold badges31 silver badges53 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 14

You can use:

type Props = {
  doSomething: () => void,
}

or specify arguments if needed.

There is a clearer way:

type Props = {
  doSomething: Function // with capital letter
}
发布评论

评论列表(0)

  1. 暂无评论