I can't figure out what this does or even is. Would someone please be so kind to point me what to research?
circle: (null : ?{ setNativeProps(props: Object): void }),
It's part of a React Native example and is part of a React Native class definition. The outer parts are (abbreviated):
var NavigatorIOSExample = React.createClass({
...
circle: (null : ?{ setNativeProps(props: Object): void }),
...
});
I assume it's some tricky use of the ternary operator. An anonymous function. But?
Source: https://facebook.github.io/react-native/docs/panresponder.html
The declaration is syntax from Flow. It says that 'circle' is an object with a property that is a function named 'setNativeProps':
{ setNativeProps(props: Object): void }
It also says that circle is nullable (indicated by the preceding '?') and that the default value will be null until an object of the specified type has been assigned to it.
If you look further down the sample you can see how calling code checks that circle has been assigned before calling setNativeProps:
this.circle && this.circle.setNativeProps({
backgroundColor: CIRCLE_HIGHLIGHT_COLOR
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With