2

示例 https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/PanResponderExample.js#L41

var PanResponderExample = React.createClass({
  ...
  circle: (null : ?{ setNativeProps(props: Object): void })
  ...

我不知道这是什么意思circle: (null : ?{ setNativeProps(props: Object): void })

感谢您的任何建议。

4

1 回答 1

6

它是flow的类型转换,你可以在这篇文章中看到更多细节

类型转换对于检查假设和帮助 Flow 推断您想要的类型特别有用。这里有些例子:

  (x: number) // Make Flow check that x is a number
  (0: ?number) // Tells Flow that this expression is actually nullable.
  (null: ?number) // Tells Flow that this expression is a nullable number.

所以circle: (null : ?{ setNativeProps(props: Object): void })平均circle属性是一个可以为空的对象,它有一个setNativeProps方法,默认值为null.

于 2015-09-22T16:08:17.280 回答