I am currently using axios to fetch data from my backend. The data consists of a string format similar to
"phone number: {enter phone number here}"
.
My goal is to add CSS styling wherever there is a curly brace.
let testString = "hello this is my {test} string";
testString = testString.replaceAll("{", "<span style={{color: 'red'}}>");
testString = testString.replaceAll("}", "</span>");
There are different ways I plan to incorporate the data:
1. Inside the value of a TextField
<TextField
rows={12}
multiline
value={testString}
></TextField>
2. Inside a div
<div contenteditable="true">{testString}</div>
However, instead of applying the intended CSS, it simply displays it as a string.
hello this is my <span style={{color: 'red'</span></span>>test</span> string