SamKirklandWA SamKirklandWA - 1 year ago 91
React JSX Question

React: text in state rendered as it is

I have a react code and I want to render state as

. It is rendered, but not as expected. Here's the state:

constructor(props) {
this.state = {text: "<i>Hello, this is Introduction</i>"};

This is rendered as:

<i>Hello, this is Introduction</i>

Is there a way to render it as

Hello, this is Introduction

Answer Source

One of many ways to do it is to put text in state like this:

this.state = {text: "Hello, this is Introduction"};

and render the state's text using italic this

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download