remove removeNewLine and add .trim to length variable

This commit is contained in:
kamos1
2017-10-06 13:25:32 -06:00
parent 8ab31d7009
commit e95e0381c2
+1 -6
View File
@@ -82,15 +82,10 @@ export class CommentForm extends React.Component {
}
}
removeNewLine = (string) => {
return string.replace(/\n/g, '');
}
render() {
const {maxCharCount, submitEnabled, cancelButtonClassName, submitButtonClassName, charCountEnable, body, loadingState} = this.props;
const cleanedBody = this.removeNewLine(body);
const length = cleanedBody.trim().length;
const length = body.trim().length;
const isRespectingMaxCount = (length) => charCountEnable && maxCharCount && length > maxCharCount;
const disableSubmitButton = !length || isRespectingMaxCount(length) || !submitEnabled({body}) || loadingState === 'loading';
const disableCancelButton = loadingState === 'loading';