enanced comment body

This commit is contained in:
ue 2019-12-14 16:21:44 +03:00
parent d63cbd5c08
commit 7210b27e6d

View File

@ -1,9 +1,9 @@
import React, { Fragment } from 'react'; import React from 'react';
import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native'; import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native';
import { withNavigation } from 'react-navigation'; import { useIntl } from 'react-intl';
import { useIntl, injectIntl } from 'react-intl';
import HTML from 'react-native-render-html'; import HTML from 'react-native-render-html';
import { getParentsTagsRecursively } from 'react-native-render-html/src/HTMLUtils'; import { getParentsTagsRecursively } from 'react-native-render-html/src/HTMLUtils';
import { navigate } from '../../../../navigation/service';
// Constants // Constants
import { default as ROUTES } from '../../../../constants/routeNames'; import { default as ROUTES } from '../../../../constants/routeNames';
@ -13,13 +13,7 @@ import styles from './postBodyStyles';
const WIDTH = Dimensions.get('window').width; const WIDTH = Dimensions.get('window').width;
const CommentBody = ({ const CommentBody = ({ body, textSelectable = true, handleOnUserPress, handleOnPostPress }) => {
navigation,
body,
textSelectable = true,
handleOnUserPress,
handleOnPostPress,
}) => {
const intl = useIntl(); const intl = useIntl();
const _handleOnLinkPress = (href, hrefAtr) => { const _handleOnLinkPress = (href, hrefAtr) => {
@ -56,7 +50,7 @@ const CommentBody = ({
const _handleOnPostPress = (permlink, author) => { const _handleOnPostPress = (permlink, author) => {
if (permlink) { if (permlink) {
navigation.navigate({ navigate({
routeName: ROUTES.SCREENS.POST, routeName: ROUTES.SCREENS.POST,
params: { params: {
author, author,
@ -69,7 +63,7 @@ const CommentBody = ({
const _handleOnUserPress = username => { const _handleOnUserPress = username => {
if (username) { if (username) {
navigation.navigate({ navigate({
routeName: ROUTES.SCREENS.PROFILE, routeName: ROUTES.SCREENS.PROFILE,
params: { params: {
username, username,
@ -164,7 +158,6 @@ const CommentBody = ({
const _initialDimensions = { width: WIDTH - 50, height: 80 }; const _initialDimensions = { width: WIDTH - 50, height: 80 };
return ( return (
<Fragment>
<HTML <HTML
html={body} html={body}
onLinkPress={(evt, href, hrefAtr) => _handleOnLinkPress(evt, href, hrefAtr)} onLinkPress={(evt, href, hrefAtr) => _handleOnLinkPress(evt, href, hrefAtr)}
@ -181,15 +174,9 @@ const CommentBody = ({
alterData={_alterData} alterData={_alterData}
renderers={_customRenderer} renderers={_customRenderer}
/> />
</Fragment>
); );
}; };
const areEqual = (prevProps, nextProps) => { const areEqual = (prevProps, nextProps) => prevProps.body !== nextProps.body;
if (prevProps.body !== nextProps.body) {
return true;
}
return false;
};
export default React.memo(injectIntl(withNavigation(CommentBody)), areEqual); export default React.memo(CommentBody, areEqual);