update upvote state inside post card

This commit is contained in:
Nouman Tahir 2021-03-30 12:51:17 +05:00
parent 4032217c11
commit db823b76f1
2 changed files with 10 additions and 1 deletions
src/components/postCard

View File

@ -32,7 +32,7 @@ const PostCardContainer = ({
}) => {
const [_content, setContent] = useState(content);
const [reblogs, setReblogs] = useState([]);
const [activeVotes, setActiveVotes] = useState(get(_content, 'active_votes', []));
const [activeVotes, setActiveVotes] = useState(get(content, 'active_votes', []));
//NOTE: potentially unnessacry fetch
// useEffect(() => {
@ -41,6 +41,11 @@ const PostCardContainer = ({
// }
// }, [isRefresh]);
useEffect(() => {
setContent(content);
setActiveVotes(get(content, 'active_votes', []));
}, [content]);
useEffect(() => {
let isCancelled = false;

View File

@ -43,6 +43,10 @@ const PostCardView = ({
const [activeVotesCount, setActiveVotesCount] = useState(activeVotes.length || 0);
const [calcImgHeight, setCalcImgHeight] = useState(imageHeight || 300);
useEffect(() => {
setActiveVotesCount(activeVotes.length);
}, [activeVotes]);
// Component Functions
const _handleOnUserPress = () => {