rn-material-ui-textfield
Version:
37 lines (28 loc) • 823 B
JavaScript
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import { Text } from 'react-native';
import { TextPropTypes } from 'deprecated-react-native-prop-types';
import styles from './styles';
export default class Counter extends PureComponent {
static propTypes = {
count: PropTypes.number.isRequired,
limit: PropTypes.number,
baseColor: PropTypes.string.isRequired,
errorColor: PropTypes.string.isRequired,
style: TextPropTypes.style,
};
render() {
let { count, limit, baseColor, errorColor, style } = this.props;
if (!limit) {
return null;
}
let textStyle = {
color: count > limit ? errorColor : baseColor,
};
return (
<Text style={[styles.text, style, textStyle]}>
{count} / {limit}
</Text>
);
}
}