react-native Button

前端之家收集整理的这篇文章主要介绍了react-native Button前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import React,{ PropTypes } from 'react';
import {
  View,Text,TouchableOpacity
} from 'react-native';

const propTypes = {
  onPress: PropTypes.func,disabled: PropTypes.bool,style: Text.propTypes.style,containerStyle: View.propTypes.style,text: PropTypes.string,activeOpacity: PropTypes.number
};

const Button = ({ onPress,disabled,style,containerStyle,text,activeOpacity }) => (
  <TouchableOpacity
    style={containerStyle}
    onPress={onPress}
    disabled={disabled}
    activeOpacity={activeOpacity}
  >
    <Text style={style}>
      {text}
    </Text>
  </TouchableOpacity>
);

Button.propTypes = propTypes;

Button.defaultProps = {
  onPress() {},disabled: false,activeOpacity: 0.8
};

export default Button;

猜你在找的React相关文章