question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extract true vs false inconsistencies

See original GitHub issue

Currently, 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:open
  • Created 6 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

10reactions
jburghardtcommented, Feb 1, 2018

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

2reactions
albertogasparincommented, May 23, 2017

Great, version 3.0.1 correctly set the viewbox attribute, however the id 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 original id and use tags with the -usage id. However, the style inside the svg hides all use#xyz-usage elements so the icons do not appear as the imported id refers to the hidden use tag, not the symbol.

  • svg <symbol id="icon" /> is correct
  • svg <use id="icon-usage" /> has display none
  • import icon returns id=icon-usage when extract mode is true, which is hidden

I could replace the -usage in the id string in my own components (or add a css that forces the sprite-symbol-usage display) , but I still think that id should be consistent regardless of the extract flag, and the -usage suffix should only be added on the url property (where it makes sense).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found