aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-04 20:07:03 -0400
committerIvan Chen <ivan@tagg.id>2021-05-04 20:48:09 -0400
commitc23feea922da063d88d031f25b72b53ba593ec04 (patch)
tree060c94fdb8d03575d91235ca8772fcb842bdbc25 /src
parent2832decea88ed14325f92759617ae8ee8a588d22 (diff)
fixed type warning
Diffstat (limited to 'src')
-rw-r--r--src/components/comments/CommentTile.tsx7
-rw-r--r--src/utils/comments.tsx10
2 files changed, 14 insertions, 3 deletions
diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx
index 37a249a8..12f32c95 100644
--- a/src/components/comments/CommentTile.tsx
+++ b/src/components/comments/CommentTile.tsx
@@ -14,7 +14,7 @@ import {deleteComment, getCommentsCount} from '../../services';
import {RootState} from '../../store/rootReducer';
import {CommentThreadType, CommentType, ScreenType} from '../../types';
import {getTimePosted, normalize, SCREEN_WIDTH} from '../../utils';
-import {mentionPartTypes, renderValue} from '../../utils/comments';
+import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments';
import {ProfilePreview} from '../profile';
import CommentsContainer from './CommentsContainer';
@@ -136,7 +136,10 @@ const CommentTile: React.FC<CommentTileProps> = ({
/>
<TouchableOpacity style={styles.body} onPress={toggleAddComment}>
<View style={styles.comment}>
- {renderValue(commentObject.comment, mentionPartTypes)}
+ {renderTextWithMentions({
+ value: commentObject.comment,
+ partTypes: mentionPartTypes,
+ })}
</View>
<View style={styles.clockIconAndTime}>
<ClockIcon style={styles.clockIcon} />
diff --git a/src/utils/comments.tsx b/src/utils/comments.tsx
index a1f353d6..c0b522f2 100644
--- a/src/utils/comments.tsx
+++ b/src/utils/comments.tsx
@@ -43,6 +43,11 @@ const renderPart = (part: Part, index: number) => {
);
};
+interface RenderProps {
+ value: string;
+ partTypes: PartType[];
+}
+
/**
* Value renderer. Parsing value to parts array and then mapping the array using 'renderPart'
*
@@ -51,7 +56,10 @@ const renderPart = (part: Part, index: number) => {
* @param value - value from MentionInput
* @param partTypes - the part types array that you providing to MentionInput
*/
-export const renderValue: React.FC = (value: string, partTypes: PartType[]) => {
+export const renderTextWithMentions: React.FC<RenderProps> = ({
+ value,
+ partTypes,
+}) => {
const {parts} = parseValue(value, partTypes);
return <Text>{parts.map(renderPart)}</Text>;
};