为了可读性,有没有办法把
上下文类型
和
默认道具
在无状态反应组件之前?
type TopBarProps = {
children: string,
color: string
};
TopBar.defaultProps = {
color: "white"
};
TopBar.contextTypes = {
locale: PropTypes.string,
colors: PropTypes.object,
i18n: PropTypes.object,
fontFamily: PropTypes.object,
scale: PropTypes.number,
alignStyle: PropTypes.string,
navMethods: PropTypes.object,
token: PropTypes.string,
arrowName: PropTypes.string,
materialArrows: PropTypes.object
};
export const TopBar = (props: TopBarProps, context) => {
const { colors } = context;
styles = styles || initStyles(context);
return (
<View style={styles.container}>
<View>
<Menu color={colors.colorFont} />
</View>
<View>
<TopLabel color={props.color}>{props.children}</TopLabel>
</View>
</View>
);
};