N
N
nepster-web2021-02-09 20:20:27
typescript
nepster-web, 2021-02-09 20:20:27

How to render html in react component?

Hello.

Got a project for support, it has a component for translations. Which, given the key trans::key, returns a translation string, which may contain html. The render looks like this (using TypeScript):

<Trans item="trans::key" />



const ComText = () => {
    return (<Trans item="trans::key" />);
};

export default ComText;


The output is:
6022c317b3377316406686.png

dangerouslySetInnerHTML does not crash because of the type script

How can you render html in such a situation ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2021-02-09
@vabka


dangerouslySetInnerHTML does not fly due to typescript

Baking as any or as unknown
Profit.
Maybe something new has been added to react for this, so I'll wait for more answers

A
Artem Volkov, 2017-09-02
@rugrisser

$_SESSION;
Read here
php.net/manual/ru/ref.session.php

S
Sergey Andrievsky, 2017-09-03
@Andriyevski

https://habrahabr.ru/post/13726/
https://ruseller.com/lessons.php?rub=37&id=347
www.internet-technologies.ru/articles/article_2077.html
https://habrahabr.ru/ post/114661/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question