Extract true vs false inconsistencies
See original GitHub issueCurrently, I’m using v2.1.0 and my code looks like:
import icon from './icon.svg';
// ...
<svg viewBox={icon.viewBox}>
<use xlinkHref={`#${icon.id}`} />
</svg>
This works perfectly when extract: false
.
However, whenever I set extract: true
, icon
is now a string
. I could check the type of icon
but the problem is that viewBox
is no longer available.
May I ask you why? Or am I using the loader in the wrong way?
PS: I read that providing a custom runtimeGenerator
could solve my issue, however sounds a bit overkill, especially because I might need to copy-paste all default generator code, just without an if statement.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (13 by maintainers)
Top Results From Across the Web
Inconsistency
Because the study of inconsistency requires you to know what the words "true" and "truth" mean, it might help you to have a...
Read more >9.1: Recognizing Inconsistency and Contradiction
Because the study of inconsistency requires you to know what the words "true" and "truth" mean, it might help you to have a...
Read more >Inconsistency between TRUE and FALSE constant definitions ...
true is defined as true and false is defined as false . It's merely the type casting rules that you're stumbling over (and...
Read more >Consistent vs Inconsistent Sets of Claims | Free Video Tutorial
We say that a set of claims if consistent if it's logically possible for all of them to be true at the same...
Read more >The mental representation of true and false intentions
True and false intentions (i.e., lies and truths about one's future actions) is a relatively new research topic, despite the high societal ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
why does the id of the icons differ in the mode ?
should it not generate the same id ?
#icon in runtime mode. #sprite.svg#icon in extract mode.
having the sprite-loader add the -usage string to every id is very confusing
Great, version 3.0.1 correctly set the
viewbox
attribute, however theid
is still problematic. The issue with the current output is that icons do not work if the svg is inlined in the page (technique used to support all browsers).What happens is that the svg generated has
symbol
with the originalid
anduse
tags with the-usage
id
. However, the style inside the svg hides alluse#xyz-usage
elements so the icons do not appear as the importedid
refers to the hiddenuse
tag, not thesymbol
.<symbol id="icon" />
is correct<use id="icon-usage" />
has display noneimport icon
returnsid=icon-usage
when extract mode istrue
, which is hiddenI could replace the
-usage
in theid
string in my own components (or add a css that forces thesprite-symbol-usage
display) , but I still think thatid
should be consistent regardless of the extract flag, and the-usage
suffix should only be added on theurl
property (where it makes sense).