Skip to content

Dependency Array Issue in useMemo in Assignment2 Component #1004

@shubhhhGT

Description

@shubhhhGT

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]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions