D
D
dmitriu2562020-08-12 18:05:11
JavaScript
dmitriu256, 2020-08-12 18:05:11

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
          ]
        };

Output in the render() method
{this.state.numbers.map((number, index) => {
                            return (
                                <Number key={index} title={number.title} descr={number.descr}/>
                            );
                        })
                        }

Result
5f3404ac10aa8269296049.png
I would be grateful for the answers

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sakhnyuk, 2020-08-12
@dmitriu256

HTML can be inserted through the dangerouslySetInnerHTML prop

<div dangerouslySetInnerHTML={{__html: stringHtml}} />

But you should be careful with this. You can read here

F
FanatPHP, 2015-03-30
@FanatPHP

yours like this:
$price = intval(str_replace(' ', '', $price));

R
Rikcon, 2015-03-30
@Rikcon

$b = '128'; 
$c = intval($b);

echo gettype($c);

strange, but if you do it like this, it will return an integer, and if gettype(intval($b));
it's a string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question