The port of Rails's simple_format to React.
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>
Default is 'div'
, but you can change it to something else:
<SimpleFormat text={ ... } wrapperTag='article' />
↓
<article>
...
</article>
---
<SimpleFormat text={ ... } wrapperTag={ SomeComponent } />
↓
<SomeComponent>
...
</SomeComponent>
props
for the wrapper tag.
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>
MIT