How to Fix Gatsby.js StaticImage Not Updating
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
⇨ Table of Contents for React Articles
This article explains how to fix the issue when Gatsby's StaticImage doesn't update.
Introduction
When using gatsby-plugin-image
:
<StaticImage src="path" alt="" />
Even after changing the src
, the image does not update. This article addresses that issue.
Solution
Clear the Cache
When you change an image but keep the same filename, Gatsby sometimes doesn’t switch the images properly.
In such cases, deleting the cache and regenerating the site should fix the problem.
gatsby clean
gatsby develop
After regenerating, the image should be displayed correctly.
Conclusion
That's it! I hope this helps someone.
→ Read more about using gatsby-plugin-images in this article