I have a function that returns a string of a number of divs equal to the number passed to it. When I call the function in my component it just shows the string of HTML code instead of interpreting it. I tried writing a div outside of the curly braces to see how it would evaluate. It makes the blue square at the bottom of the upper left square, so that works. Any ideas why the string returned from my function is not showing as intended?
const drawHpBar=function(hp){
let hpBars = "";
for(let i=0;i<hp;i++){
hpBars = hpBars + '<div className="hpTick" id='+'"'+i+'"'+'></div>'
}
return hpBars;
}
class CharPic extends Component {
render() {
const hp=this.props.hp;
return (
<div className="menuBox" id="charPic">
CharPic HP{this.props.hp}
<br/>
<div className="hpBar">
{drawHpBar(hp)}
</div>
<div className="hpTick"/>
</div>
);
}
}
Screenshot: