1
I have the following code:
{
this.state.listSkills.map(function(habilidade){
return (
<ul className="habilidades">
<li className="habilidade-"{habilidade.value}>
<h2>{habilidade.name}
<div className="barra"><span></span></div>
</h2>
</li>
</ul>
);
})
}
The value of the variable habilidade.value
comes from a dynamic json with a value and a percentage symbol (%
), example: 10%
.
I need to concatenate the string "habilidade"
with this variable and take the %
to keep class="habilidade-10"
. How to do?
Where exactly you need this value?
– Francisco
in Sass, so I can use it when it is rendered @for $i from 0 through 100{ li.ability-#{$i}{ . barra{ span{ width: 1% * $i; } } }
– Felipe
Try
className={"habilidade-" + habilidade.value.replace('%', '')}
– Francisco
It worked, thank you very much!
– Felipe
I created an answer to help other users who have the same problem in the future. If you can, mark it as correct.
– Francisco