0

I use React JS, and I want to make a universal component, to show message for user. Like as at image: enter image description here

I want to send text like as this : "Lorem ipsum ["Link"](url) Lorem ipsum **Strong text**". How I may parse this with JavaScript? I can imagine how to implement this, but I would not like to reinvent my wheel, maybe there are some ready-made and elegant solutions?

1
  • 1
    You can use react-markdown to parse markdown Commented Aug 28, 2022 at 13:54

1 Answer 1

1

What you need is a Markdown component for React. Try react-markdown:

import React from 'react';
import ReactDom from 'react-dom';
import ReactMarkdown from 'react-markdown';
ReactDom.render(
    <ReactMarkdown>
        Lorem ipsum [link](url) <br />
        Lorem ipsum **Strong text**
    </ReactMarkdown>,
    yourElement
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.