react-markup-text

2.2.0 • Public • Published

react-markup-text

markup texts with React

Use this package to add paragraphs and line endings to unstructured text

Install

npm install --save react-markup-text

Usage

import textToReactMarkup from 'react-markup-text';
 
function BlogArticle({ title, author, body }) {
    return (
        <article className="blog-article">
            <h1 className="blog-article__title">{title}</h1>
            <AuthorBadge author={author} />
            <div className="blog-article__body">
                {textToReactMarkup(body)}
            </div>
        </article>
    );
}

API

textToReactMarkup(text: string) : Array<ReactElement>

The implementation is really simple, \n\n creates a new paragraph and \n a new line.

License

ISC

Package Sidebar

Install

npm i react-markup-text

Weekly Downloads

1

Version

2.2.0

License

ISC

Last publish

Collaborators

  • mattecapu