Inconsistent rendering when multiple components share same src and request fails (cache + LOADED empty state)
#249
VanMaiTrai
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🐛 Inconsistent rendering when multiple components share same
srcand request fails (cache + LOADED empty state)Hi maintainers 👋,
I’ve encountered an inconsistent rendering issue when using multiple
<InlineSVG />components with the samesrc, especially when the request fails (e.g. 404).📌 Problem summary
When rendering two components with the same
src:The first component correctly falls back to
children(status =FAILED)The second component renders nothing (status =
LOADED, butelement = null)🔁 Reproduction scenario
Assume
/not-found.svgreturns:404 Not Foundcontent-type: text/html🔍 Observed behavior
First component:
fetch()throws → cache sets:Hook sets
status = FAILED→ correctly renders fallback (
children) ✅Second component:
cacheStore.get()returnscontent = ""BUT does not propagate
FAILEDstateHook sets:
Since:
element === nullstatus !== FAILED→ component falls through to:
→ ❌ renders nothing (no fallback, no error)
1. CacheStore loses FAILED state
Only returns
contentDoes not expose
statusSo FAILED → becomes indistinguishable from LOADED with empty content
2. Hook assumes
LOADED= valid contentIf
content === "", it skips conversionLeaves:
3. InlineSVG does not handle
LOADED + null elementMissing case:
💥 Result
Inconsistent UI:
✅ Suggested fixes
Option 1 — Propagate FAILED from cache
Option 2 — Validate content before marking LOADED
Option 3 — Defensive fallback in InlineSVG
💡 Additional note
This issue becomes more visible when:
Multiple components share the same
srccacheRequests = true(default)The request fails or returns invalid content
🙏 Expected behavior
All components with the same failing
srcshould behave consistently:👉 Either:
All render fallback
or
All render error state
But not a mix of fallback + empty render
Let me know your thoughts — happy to help test or open a PR 👍
Beta Was this translation helpful? Give feedback.
All reactions