Answer the question
In order to leave comments, you need to log in
Is it safe to use dangerousSetInnerHTML in this case?
I implement a sadgest like a Yandex sadgest. I need to highlight matching results in sadgest based on the value of the input. In general, in fact, as in the Yandex search bar.
Yandex highlighting comes from tags . Our search on the back is elastic, and the back can send me data in the same form with , but I can only insert them as HTML
through dangerouslySetInnerHTML do I get renders from the backend, not from user input?
And if this implementation is not the best option, then how to do it better? Regulars? <b>
<b>
Answer the question
In order to leave comments, you need to log in
If you are sure that only text with tags will come to you <b>
, then there is no danger.
The property has the word dangerously in its name so that programmers remember that this is a potentially dangerous action, and not because any use of it is dangerous and not desirable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question