Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flow: What is the equivalent of PropTypes.func in flow?

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

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> {}
like image 351
acmoune Avatar asked Dec 01 '22 10:12

acmoune


2 Answers

You can use:

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

or specify arguments if needed.

like image 154
mersocarlin Avatar answered Dec 04 '22 07:12

mersocarlin


There is a clearer way:

type Props = {
  doSomething: Function // with capital letter
}
like image 39
Alexey Kutalo Avatar answered Dec 04 '22 05:12

Alexey Kutalo