From b3041bb521fc4f52b414151eb4d8220791f6c874 Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Tue, 25 May 2021 13:00:10 -0700 Subject: Load tags in PostContent when moment tags changes --- src/components/moments/MomentPostContent.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index 6953dca4..c3cb03f5 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -4,7 +4,7 @@ import {Image, StyleSheet, Text, View, ViewProps} from 'react-native'; import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; import Animated, {Easing} from 'react-native-reanimated'; import {useDispatch, useStore} from 'react-redux'; -import {getCommentsCount, loadMomentTags} from '../../services'; +import {getCommentsCount} from '../../services'; import {RootState} from '../../store/rootReducer'; import {MomentTagType, ScreenType, UserType} from '../../types'; import { @@ -24,6 +24,7 @@ interface MomentPostContentProps extends ViewProps { caption: string; pathHash: string; dateTime: string; + momentTags: MomentTagType[]; } const MomentPostContent: React.FC = ({ screenType, @@ -32,10 +33,11 @@ const MomentPostContent: React.FC = ({ pathHash, dateTime, style, + momentTags, }) => { const [elapsedTime, setElapsedTime] = useState(''); const [comments_count, setCommentsCount] = useState(''); - const [tags, setTags] = useState([]); + const [tags, setTags] = useState(momentTags); const [visible, setVisible] = useState(false); const state: RootState = useStore().getState(); const navigation = useNavigation(); @@ -47,14 +49,8 @@ const MomentPostContent: React.FC = ({ ); useEffect(() => { - const loadTags = async () => { - const response = await loadMomentTags(momentId); - if (response) { - setTags(response); - } - }; - loadTags(); - }, []); + setTags(momentTags); + }, [momentTags]); useEffect(() => { const fetchCommentsCount = async () => { -- cgit v1.2.3-70-g09d2