Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-break-newlines

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-break-newlines

Break a string to lines at newlines, and either wrap each line by a configurable wrapper or append a `` to each line.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Package Dependency status devDependency status

react-break-newlines

Break a string to lines at newlines, and either wrap each line by a configurable wrapper or append a <br /> to each line.

Install

npm install react-break-newlines

Usage

import breakNewlines from 'react-break-newlines';

// The string to break.
var str = 'paragraphs\nwith\nnewlines';

// Case 1: Break without a wrapper.
breakNewlines( str );
// Gives [
//   paragraphs<br key="0">,
//   with<br key="1">,
//   newlines<br key="2">
// ]

// Case 2: Break with a <p> wrapper.
breakNewlines( str, 'p' ); // Or breakNewlines( str, <p /> );
// Both give
// [
//   <p key="0">paragraphs</p>,
//   <p key="1">with</p>,
//   <p key="2">newlines</p>
// ]

// Case 3: Break with a wrapper made of a React component.
const Wrapper = props => <div>Wrapper { props.children }</div>;
breakNewlines( str, Wrapper ); // Or breakNewlines( str, <Wrapper /> );
// Both give
// [
//   <Wrapper key="0"><div>Wrapper paragraphs</div></Wrapper>,
//   <Wrapper key="1"><div>Wrapper with</div></Wrapper>,
//   <Wrapper key="2"><div>Wrapper newlines</div></Wrapper>
// ]

License

MIT. See LICENSE.md for details.

Keywords

FAQs

Package last updated on 21 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc