Question from the React ⚛️ test

Fix the useMemo hook in this React component.

Hard
const SomeComponent=({name, firstName})=>{
    if(!name){
        return null;
    }
    
    const uppercaseName= useMemo(()=>firstName.toUpperCase(),[]);
    return<span>${`${name} ${uppercaseName}`}</span>;
};

What are the issues with this code?

Author: Clément DEVOSStatus: PublishedQuestion passed 4050 times
Edit
5
Community Evaluations
developer avatar
Camille
12/10/2024
the firstName prop might be undefined. Maybe replace `if (!name) { return null; } ` with ` if (!name || !firstName) { return null; } `
developer avatar
Spelling / formatting error
Hanane
08/01/2024
toUppercase() => toUpperCase()
developer avatar
Ambiguous
Nice Alligator
08/07/2024
wrong answer to the question
developer avatar
Константин
13/08/2023
Bad question with wrong answer