Here's my situation:
This is a Single Page App that is using react-router-dom to perform client-side routing.
I have a AddBlogPostPage where the admin will create blogPosts.
- This page has lots of inputs and textareas to build the
blogPostparagraphs and images. - Inside a
textareainput, the admin will enter a paragraph text that will be rendered inside a<p>tag usingdangerouslySetInnerHTMLwhen theblogPostis displayed. - But sometimes is necessary to add links to other pages of the App and I'm doing the following:
- The admin enters in the
textarea:- For example: the text pattern
[products](/products) - And this gets replaced and rendered as
<a href="/products">products</a>
- For example: the text pattern
But when I click on the <a> the App refreshes other than switch routes with react-router-dom. That is because I'm using an <a> tag instead of a Link component that comes built-in with react-router-dom.
But since I'm rendering my paragraphs with dangerouslySetInnerHTML, how can I display the React component Link instead of an html tag <a> in this situation?
From my research so far, this does not seem to be possible. Is there any other way around this?