Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactderived vs stored stateSingle-choice MCQ

A component does `const [fullName, setFullName] = useState(firstName + ' ' + lastName)` where `firstName` and `lastName` are props. The parent later updates `lastName`. Why does `fullName` not update?

function Profile({ firstName, lastName }) { const [fullName, setFullName] = useState(firstName + ' ' + lastName); return <h1>{fullName}</h1>; }