Answer the question
In order to leave comments, you need to log in
How to write a line with html tags in state?
The question is very simple how to write a line with a tag in state so that it is displayed correctly on the page
If the tag is written in the component, then 5 years will be squared, which is not good
this.state = {
numbers: [
{title: '5 лет', descr: 'На рынке изделий из гофрокартона'},
{title: 'до 5 000 000 м <sup>2</sup>', descr: 'Ежемесячный объем производства гофрокартона'},
//как пробовал
{title: `4 000 м${<sup>2</sup>}` descr: 'Площадь склада'}, - выдает 4000 и objectObject
]
};
{this.state.numbers.map((number, index) => {
return (
<Number key={index} title={number.title} descr={number.descr}/>
);
})
}
Answer the question
In order to leave comments, you need to log in
HTML can be inserted through the dangerouslySetInnerHTML prop
<div dangerouslySetInnerHTML={{__html: stringHtml}} />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question