The `style` attribute expects a mapping from style attributes to values
P粉817354783
2023-08-15 15:37:44
<p>While creating a front and back image slider using React, I encountered this error.
I don't know if I need to import it but unfortunately it is an external file.
Any tips and suggestions would be greatly appreciated</p>
<pre class="brush:php;toolbar:false;"><div class="scroller scroller-top">
<svg class="scroller__thumb" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><polygon points= "0 50 37 68 37 32 0 50" style="fill:rgb(24,24,62)"/><polygon points="100 50 64 32 64 68 100 50" style="fill:rgb(24 ,24,62)"/></svg>
</div></pre>
<p>I expected to see the SVG icon, but instead an error was thrown as described above</p>
You can add the
fill
attribute directly on the polygon as follows:Bonus: If you are using React, the
class
attribute should beclassName
.