0

I have a very specific problem, so: I have a medium text in My MySQL database. for example (with breakline):

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

I would like to get this text now using the get HTTP method and on my site display, all Lorem Ipsum in bold.

Is something possible to get? I use ReactJS with Redux + Redux-Saga

or Maybe IN databases, I can insert the medium text in html but how to display it on the frontend then?

promiseREact5
  • 375
  • 1
  • 3
  • 5

1 Answers1

0

Store html and use dangerouslySetInnerHTML to render it. You can have a deeper look into it reading this post.

const text = '<strong>Lorem ipsum</strong> dolor sit';

const App = ({html}) => (
  <div dangerouslySetInnerHTML={{ __html: html }} />
)

ReactDOM.render(<App html={text} />, document.getElementById('root'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>
gazdagergo
  • 6,187
  • 1
  • 31
  • 45