Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 562 Bytes

README.md

File metadata and controls

32 lines (22 loc) · 562 Bytes

react-js-nl2br

Replacing newline char with <br> in React

Does not generate any extra empty unnecessary lines and <br>

Install

npm i react-js-nl2br

or

yarn add react-js-nl2br

Get started

import React from 'react';
import { nl2br } from 'react-js-nl2br';

function Component({ text }) {
    return (
        <div>{ nl2br(text) }</div>
    );
}

Do not rush to use this plugin, perhaps this CSS property will help you solve the problem: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space 😉