Handling with the JSON data in the applications sometimes we face issues of HTML tags coming from back-end . So how to resolve this issue?
We can resolve by using regular expression and javascript function like replace. Below is the snippet for this issue.
if (this.state.content!= undefined) {// checked whether it exists or not.var regex = /(<([^>]+)>)/gi//regular expressionvar des =this.state.contentvar res = des.replace(”, ”)var res = des.replace(regex, ”)//will replace the tags with blank}
Now you can use res variable in the render function directly in the render function.
Leave a comment