【发布时间】:2017-10-01 18:16:12
【问题描述】:
在 react-native 中为流定义 proptypes 的正确方法是什么?我正在寻找一些指导方针。
// @flow
import React from 'react';
import { TouchableOpacity, Image, StyleSheet } from 'react-native';
type Props = {
style?: StyleSheet.Styles,
onPress: () => mixed,
source: Image.propTypes.source
};
const IconButton = (props: Props) => (
<TouchableOpacity onPress={props.onPress}>
<Image style={props.style} source={props.source} />
</TouchableOpacity>
);
IconButton.defaultProps = {
style: {}
};
导出默认图标按钮;
我的使用方法是这样的:
<IconButton
onPress={()=>{}}
style={this.props.style}
source={require('./assets/images/circle.png')}
/>
【问题讨论】:
标签: react-native flowtype