diff --git a/components/TwitterContainer.jsx b/components/TwitterContainer.jsx index bb0c9d5b5..c39a3fb97 100644 --- a/components/TwitterContainer.jsx +++ b/components/TwitterContainer.jsx @@ -1,9 +1,22 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import TwitterResultCard from '@components/TwitterResult'; import useFetch from '@hooks/use-fetch'; const Selector = ({ searchStr, resourceType, noRes, noResText }) => { const [covidConnectResults, loading] = useFetch({ city: searchStr, materialType: resourceType }); + const [tweets, setTweets] = useState(covidConnectResults); + useEffect(() => { + const memo = {}; + const filteredResults = covidConnectResults.filter(result => { + if(!(result.full_text in memo)) { + memo[result.full_text] = true; + return true; + } + return false; + }); + + setTweets(filteredResults); + }, [covidConnectResults, loading]); return (