React js render html string returned from server

IMOBAMA

From php im returning this html

PHP

$str = "Hello World";
echo json_encode("returnval"=>format_string($str));

function format_string($str){
  return "<b>".$str."</b>";
}

React JSX

render () => {
   //returnval = html string returned from php

   return (
     <div>
         {returnval} 
         <div>
              <span>Some data</span>
         </div>
     </div>
   );
}

The above prints <b>Hello World</b> as a text .

But i want the html tags to be executed (in this case as bold)

I cannot write the format_string function in jsx for some reasons is there any way around this ?

MattYao

You can use dangerouslySetInnerHTML attributes to render your html strings.

Check React doc (https://facebook.github.io/react/docs/dom-elements.html) for more details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

String Interpolation in React component with strings returned from server

From Dev

React render array returned from map

From Dev

Render dynamic html in react js

From Dev

React render components from string

From Java

Render HTML string as real HTML in a React component

From Dev

Get String Value Returned From SQL Server

From Dev

How to access a string returned from the server

From Dev

Render React JS server side using .net

From Dev

How to render a react element using an html string?

From Dev

React.js render text as HTML

From Dev

Render returned string in django template

From Dev

How to render a react component from a string name

From Dev

Get count of div from html string (returned from API JSON)?

From Dev

Parse XML to String where XML is returned from the server

From Dev

React server-side render or static index.html?

From Dev

Type of HTML element returned from document.getElementById String not Number

From Dev

JSF and HTML code returned as a String from Managed Bean possible?

From Dev

Type of HTML element returned from document.getElementById String not Number

From Dev

How does one set a css class on a div returned from react's render()

From Java

React - Error: App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

From Dev

How to render an html entity in React.js without JSX

From Dev

How can I generate HTML by function and render it later in JS React

From Dev

Draft.js and stateToHTML, how to render output html in react component?

From Dev

How to make React-Router to render an interactive output from the server?

From Dev

Render HTML in React Native

From Dev

why polymer not render html markup fetched from server in json format?

From Dev

Knockout render html string

From Dev

render html in state string

From Dev

Render string to html in MVC

Related Related

  1. 1

    String Interpolation in React component with strings returned from server

  2. 2

    React render array returned from map

  3. 3

    Render dynamic html in react js

  4. 4

    React render components from string

  5. 5

    Render HTML string as real HTML in a React component

  6. 6

    Get String Value Returned From SQL Server

  7. 7

    How to access a string returned from the server

  8. 8

    Render React JS server side using .net

  9. 9

    How to render a react element using an html string?

  10. 10

    React.js render text as HTML

  11. 11

    Render returned string in django template

  12. 12

    How to render a react component from a string name

  13. 13

    Get count of div from html string (returned from API JSON)?

  14. 14

    Parse XML to String where XML is returned from the server

  15. 15

    React server-side render or static index.html?

  16. 16

    Type of HTML element returned from document.getElementById String not Number

  17. 17

    JSF and HTML code returned as a String from Managed Bean possible?

  18. 18

    Type of HTML element returned from document.getElementById String not Number

  19. 19

    How does one set a css class on a div returned from react's render()

  20. 20

    React - Error: App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

  21. 21

    How to render an html entity in React.js without JSX

  22. 22

    How can I generate HTML by function and render it later in JS React

  23. 23

    Draft.js and stateToHTML, how to render output html in react component?

  24. 24

    How to make React-Router to render an interactive output from the server?

  25. 25

    Render HTML in React Native

  26. 26

    why polymer not render html markup fetched from server in json format?

  27. 27

    Knockout render html string

  28. 28

    render html in state string

  29. 29

    Render string to html in MVC

HotTag

Archive