Skip to content

Replacing newline char with <br> in React. Does not generate any extra empty unnecessary lines and <br>

Notifications You must be signed in to change notification settings

worka/react-js-nl2br

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 😉

About

Replacing newline char with <br> in React. Does not generate any extra empty unnecessary lines and <br>

Resources

Stars

Watchers

Forks

Packages