Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filtered duplicate tweets #306

Closed
wants to merge 1 commit into from
Closed

filtered duplicate tweets #306

wants to merge 1 commit into from

Conversation

khavinshankar
Copy link
Member

this resolves #297

@khavinshankar khavinshankar requested a review from a team May 29, 2021 13:06
@vercel
Copy link

vercel bot commented May 29, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/coronasafe/life/91MHvvbpsgapd6E2aQRg3e9nxEvK
✅ Preview: https://life-git-duplicate-tweets-coronasafe.vercel.app

Comment on lines +7 to +19
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]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const [covidConnectResults, loading] = useFetch({ city: searchStr, materialType: resourceType });
const removeDuplicateTweets = () => {
    const memo = {};
    const filteredResults = covidConnectResults.filter(result => {
        if(!(result.full_text in memo)) {
            memo[result.full_text] = true;
            return true;
        }
        return false;
    });
    return filteredResults;
}
const covidTweetResults = removeDuplicateTweets(covidConnectResults);

return <></>

and here,
covidConnectResults={covidTweetResults}

Instead of having a state and updating it, can we have a the simple filter function before it going to component ?
This is because already while typing, for each letter it renders the component. Having another state inside the component double the render. 🤔

Just my opinion 🤔 Can we do the above ?👆

@bodhish bodhish closed this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate tweets are being returned
3 participants