Earlier my Next.js application started throwing TypeError: Cannot read properties of null (reading 'default') without me changing anything in my code where I'm rendering some articles from our CMS.
Here is the complete log:

And here is my code:
import Image from "next/image";
export default function Articles({ articles }) {
return (
<div className="articles">
{articles.map((article) => (
<div className="article" key={article.id}>
<div className="text">
<h2>{article.title}</h2>
<p>{article.content}</p>
</div>
<div className="image">
<Image src={article.image} alt="" height={900} width={900} layout="responsive" />
</div>
</div>
))}
</div>
);
}
After some research, I found this GitHub discussion, then realized that a colleague has deleted the image of one of our articles from our CMS. If you ever come across this, the solution is to render the Image tag after a check, like so:
{ article.image ? <Image src={article.image} alt="" height={900} width={900} layout="responsive" /> : null }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With