Home > Net >  Using HTML elements while mapping
Using HTML elements while mapping

Time:11-10

I am currently fetching a data table and it has 2 values needs to be mapped. Mapping works just fine but I want to add some customisation to the text.

newDataRows(
dataToBeMapped.map((m) => ({
id: m.id, data:`<span>Bold Me:</span>${m.oldData}`
})));

I was hoping to have <span> portion to be worked but I get [object Object] on my browser. Is there any way to implement HTML in this line?

CodePudding user response:

replace data:'<span>Bold Me:</span>${m.oldData}' with data: <><span>Bold me</span>m.oldData</>

And it's not HTML it is JSX
what's JSX?

  • Related