You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
522 B
25 lines
522 B
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
const CharacterCounter = React.createClass({
|
|
|
|
propTypes: {
|
|
text: React.PropTypes.string.isRequired,
|
|
max: React.PropTypes.number.isRequired
|
|
},
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
render () {
|
|
const diff = this.props.max - this.props.text.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
|
|
|
|
return (
|
|
<span style={{ fontSize: '16px', cursor: 'default' }}>
|
|
{diff}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
});
|
|
|
|
export default CharacterCounter;
|