So I'm developing a blog page for a react application. The page is loading data from a CMS and the content of the blog post is raw html which I render on the page with:
<div dangerouslySetInnerHTML={{__html: this.state.content}} />
However any links I put in the post like
<a href='/'>Home Page</a>
don't use react router and instead trigger reloading the page.
Is there a way to handle this in react without having to parse the HTML and replace <a>
tags with <Link>
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…