# A href in a state value

**URL:** <https://forum.codewithmosh.com/t/a-href-in-a-state-value/10704>\
**Category:** React\
**Created:** [February 15, 2022, 1:51pm UTC](https://forum.codewithmosh.com/t/a-href-in-a-state-value/10704 "2022-02-15T13:51:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rene76](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rene76](https://forum.codewithmosh.com/u/rene76)\
**Post date:** [February 15, 2022, 1:51pm UTC](https://forum.codewithmosh.com/t/a-href-in-a-state-value/10704/1 "2022-02-15T13:51:13Z")

</div>

Hi,

i want to set a text in the `state object` and use this text later for a component. This text has a `<a href>` but in the rendered DOM the `a href` is displayed as text. How can i get a link?

```auto
class ClickMe extends React.Component {
  state = {
    text: 'Hi, <a href="#" target="_blank" rel="noopener nofollow">click me</a>.'
  }
  render() {
    return (
            <p>{this.state.text}</p>
    );
  }
}

ReactDOM.render(<ClickMe />, document.getElementById("root"));

```

I use the course “Mastering React”. Is there a video which answers this, please refer to it.

Best regards  
René

---

<div class="post-metadata">

**Author:** ![rene76](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rene76](https://forum.codewithmosh.com/u/rene76)\
**Post date:** [February 15, 2022, 2:35pm UTC](https://forum.codewithmosh.com/t/a-href-in-a-state-value/10704/2 "2022-02-15T14:35:29Z")

</div>

This works. But is it best practice?

```auto
state = {
    text: <React.Fragment>Hi, <a href="#" target="_blank" rel="noopener nofollow">click me</a>.</React.Fragment>
  }

```

Best regards  
René
