Personal Catalogue: React, Express & MongoDB — Chapter 7, Exercise 2 ===================================================================== TASK Temporarily revert ItemList's summary line to the naive template-literal version (`By ${item.author}`) and confirm the real "By undefined" text appears for a Cd, Dvd, or Bluray. Restore the getCreator() version and confirm the fix. SOLUTION Temporarily revert the summary line: export default function ItemList({ items, onSelect }) { return (
{`By ${item.author}`}
({item.releaseYear})By {getCreator(item)}
} {item.releaseYear && ({item.releaseYear})}is just an ordinary string like any other, and React renders it exactly as it would render "By Radiohead" -- there's no way for React to know the string came from a missing value rather than a real one. getCreator(item) never lets that coercion happen. It picks the first truthy field among author/artist/director, or returns an actual null if none exist -- and null combined with && in JSX short-circuits to null, which React explicitly recognizes as "render nothing here," rather than converting it into text first. WHY THIS WORKS AS AN ANSWER ---------------------------- It reproduces the real, literal "By undefined" bug with a real Cd document and a real observed render, explains the exact mechanism (template-literal string coercion of undefined) rather than just saying "template literals are bad," and shows the fixed version producing a genuinely different, correct result for the identical document.