All files / react-native-dropdownalert label.js

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                              2x 2x 1x           1x      
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
 
export default class Label extends Component {
  static propTypes = {
    text: PropTypes.string,
    style: PropTypes.object,
    numberOfLines: PropTypes.number,
    textProps: PropTypes.object,
  };
  static defaultProps = {
    numberOfLines: 1,
    style: {
      fontSize: 16,
      textAlign: 'left',
      fontWeight: 'normal',
      color: 'white',
      backgroundColor: 'transparent',
    },
    textProps: {},
  };
  render() {
    const { text, style, numberOfLines, textProps } = this.props;
    if (text !== null && text.length > 0) {
      return (
        <Text {...textProps} style={style} numberOfLines={numberOfLines}>
          {text}
        </Text>
      );
    }
    return null;
  }
}