Skip to content

bhtabor/react-simple-format

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-simple-format

The port of Rails's simple_format to React.

Usage

Turns double newlines into different paragraphs. See examples for live examples.

const forwardText = "You can't connect the dots looking forward;\n\nYou can only connect them looking backward."

<SimpleFormat text={ forwardText } />

This will render:

<div>
  <p>You can't connect the dots looking forward;</p>
  <p>You can only connect them looking backward.</p>
</div>

Props

wrapperTag (string/react class)

Default is 'div', but you can change it to something else:

<SimpleFormat text={ ... } wrapperTag='article' />



<article>
  ...
</article>

---

<SimpleFormat text={ ... } wrapperTag={ SomeComponent } /><SomeComponent>
  ...
</SomeComponent>

wrapperTagProps (object)

props for the wrapper tag.

postfix (node)

Allows you to add a node at the end of the last p tag.

<SimpleFormat text={ ... } postfix='foo' />



<div>
  <p>...</p>
  <p>...foo</p>
</div>

Credits

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%