'how to implement span tag in an array to html
let array= ["<span style="font-weight:900">everthing</span> is perfect", "Look for opportunities in <span style="font-weight:900">every</span>change"]
array.map((arr) => {
return (
<div>
{arr}
</div>
);
})
Desired output:
everthing is perfect Look for opportunities in every change
My output:
<span style="font-weight:900">everthing</span> is perfect
Look for opportunities in <span style="font-weight:900">every</span>change
please help me.
Solution 1:[1]
You must install a package for that.
yarn add react-html-parser
npm install react-html-parser
then.
import ReactHtmlParser from 'react-html-parser';
<div> { array.map((arr)=>(
{ReactHtmlParser (arr)}
)) } </div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zia Yamin |
