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

Dependency Array Issue in useMemo in Assignment2 Component #1004

Open
shubhhhGT opened this issue Jun 26, 2024 · 0 comments
Open

Dependency Array Issue in useMemo in Assignment2 Component #1004

shubhhhGT opened this issue Jun 26, 2024 · 0 comments

Comments

@shubhhhGT
Copy link

Title: Dependency Array Issue in useMemo in Assignment2 Component

Description:

I noticed an issue in the Assignment2 component where the sentences array is included in the dependency array for useMemo. Since the sentences array is not updated anywhere in the code, it should not be part of the dependency array.

Current Code:

const filteredSentences = useMemo(() => {
    return sentences.filter(x => x.includes(filter));
}, [sentences, filter]);

Suggested Correction:

const filteredSentences = useMemo(() => {
    return ALL_WORDS.filter(x => x.includes(filter));
}, [filter]);
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

No branches or pull requests

1 participant