diff --git a/apps/comments-ui/src/components/Comment.js b/apps/comments-ui/src/components/Comment.js index 5a5372af38..acfc4ad22d 100644 --- a/apps/comments-ui/src/components/Comment.js +++ b/apps/comments-ui/src/components/Comment.js @@ -25,7 +25,7 @@ class Comment extends React.Component { getInitials() { const comment = this.props.comment; - return this.getInitials(comment.member.name); + return getInitials(comment.member.name); } render() { @@ -39,7 +39,7 @@ class Comment extends React.Component {
-

{ getInitials() }

+

{ this.getInitials() }

Avatar
diff --git a/apps/comments-ui/src/components/Form.js b/apps/comments-ui/src/components/Form.js index f052cae26e..6cff44d706 100644 --- a/apps/comments-ui/src/components/Form.js +++ b/apps/comments-ui/src/components/Form.js @@ -1,5 +1,6 @@ import React from 'react'; import AppContext from '../AppContext'; +import {getInitials} from '../utils/helpers'; class Form extends React.Component { static contextType = AppContext; @@ -54,17 +55,7 @@ class Form extends React.Component { if (!this.context.member || !this.context.member.name) { return ''; } - const parts = this.context.member.name.split(' '); - - if (parts.length === 0) { - return ''; - } - - if (parts.length === 1) { - return parts[0].substring(0, 1); - } - - return parts[0].substring(0, 1) + parts[parts.length - 1].substring(0, 1); + return getInitials(this.context.member.name); } render() {