React does not parse the html format code obtained directly from the background, because it is to prevent XSS attacks. What is an XSS attack, which will appear in the next blog. So to let react parse the html format code obtained from the background, the following code is needed, not much to say:
import React from 'react' class IndexCom extends React.Component { constructor(props, context) { super(props, context); this.state={ div:'<div style="width: 750px;height: 200px;background: red;color: #fff;"><b>11111111111111</b></div>', } } render() { return ( <div> <div className="index"> <div dangerouslySetInnerHTML = {{ __html:this.state.div }}></div> </div> </div> ) } } export default IndexCom