Nested svg content is rendered twice
See original GitHub issueThis is a wired and annoying bug. When using a svg nested into another svg component, the content of nested svg has been drawn twice for no reason. The more strange thing with it is that one of them has drawn without respect to its parent properties (like width, height, x, y, …). My code is very complex, so I provide a simple code to reproduce the problem.
<Svg width={100} height={100} viewBox={'0 0 100 100'}>
<G key={'item touch zone'} onPress={() => {}} x={20} y={10}>
<Svg
key="item"
width={"100%"}
height={"100%"}
>
<Circle key="circle" cx="7" cy="10" r="8" fill={'green'}/>
</Svg>
</G>
</Svg>
here is the result, the right circle is what I really draw, the left one is drawn by itself!!!
I’m using version 8.0.10 (the latest one so far)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Nested svg content is rendered twice · Issue #880 - GitHub
This is a wired and annoying bug. When using a svg nested into another svg component, the content of nested svg has been...
Read more >Do browsers render all SVGs twice? - Stack Overflow
Let's add a rule for the <g> element in the <defs >, which is inside a hidden <svg> with display: none . Double...
Read more >If You're Inlining SVG Icons, How Do You Deal With Unique ...
Using the same svg in multiple places produces duplicate id's, but at the same time, the values of those titles and descriptions haven't...
Read more >Rendering a d3 chart in two places makes it render twice in ...
You need to make sure that this is not the first SVG element as seen from the document , but the first element...
Read more >Building SVG Components with React.js and d3.js - pganalyze
Mozilla's MDN has a good reference to all the element types available. The event system is very similar to what you're already used...
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
@SaeedZhiany @ReggaePanda Think I managed to replicate and fix this. Can you test with v9.2.3?
@msand Had a similar problem, I have nested circles and in case I render more than one instance of my class with svg, some additional circles appeared.
A solution was to add random Ids generated by simple Math.random() to Defs:
Hope that it would help someone with similar situation.