-1

I am trying to get the text on my page from redux state, so it can be easy changed in my backend, but the problem is that i can't use html context in this state. If i use this on my page it works fine:

<p>some text<Link to="/contact">contact</Link>more text</p>

but whenever i use:

<p>{Somevariablefromstate}</p>

with this in it: some text<Link to="/contact">contact</Link>more text it doesn't make it a link its just plain text, is there a way to prevent this?

I hope i explained it well enough to make it understandable!

Emile Bergeron
  • 16,148
  • 4
  • 74
  • 121

1 Answers1

0

<Link> is a component which will be transformed to valid HTML - most likely some <a> link. You should probably have <a href="/contact">contact</a> as a value of Somevariablefromstate variable. Plus you should most likely use https://zhenyong.github.io/react/tips/dangerously-set-inner-html.html for your <p> element so this should look like that: <p dangerouslySetInnerHTML={Somevariablefromstate} />

Wojciech Dynus
  • 881
  • 5
  • 11